简体   繁体   English

如何为“ Rate this app” iOS自定义iRate类

[英]How to customize iRate classes for “Rate this app” ios

I don't want to use the uialertview for the popup, that gives the user a chance to rate the app on ios. 我不想将uialertview用于弹出窗口,这给用户提供了在ios上对应用程序进行评分的机会。 I want to use a customized popup, but this is not showing up. 我想使用自定义的弹出窗口,但这没有显示。 Besides using the iRate classes from the internet, I also create a xib, that contains the popup, that I want to appear and I changed in .h from :NSObject to :UIViewController. 除了使用Internet上的iRate类外,我还创建了一个xib,其中包含要显示的弹出窗口,并在.h中将其从:NSObject更改为:UIViewController。 I commented all the code for the uialertview and in the method promptForRating, that will be triggered, I make the uiview from the xib visible, but apparently the uiview is nil. 我注释了uialertview的所有代码,并在了将被触发的方法hintForRating中,使来自xib的uiview可见,但显然uiview为nil。

- (void)promptForRating
{
    rateView.hidden = NO;
}

Does anybody have a suggestion about making this popup show up? 是否有人建议显示此弹出窗口?

I think I get it now.. if you want to display a view, it has to be embedded in a view controller. 我想我现在明白了..如果要显示视图,则必须将其嵌入视图控制器中。 Or in another view that is already embedded. 或在另一个已经嵌入的视图中。

What you can do is 你能做的是

  • Access the sharedApplication of the UIApplication 访问UIApplication的sharedApplication
  • Get all the UIWindows of that UIApplication (in reversed order, because your myView should be on top) 获取该UIApplication的所有UIWindows(以相反的顺序进行,因为myView应该位于顶部)
  • Select the UIWindow that is the default 选择默认的UIWindow
  • Add your myView as a subview of the UIWindow 将myView添加为UIWindow的子视图

At least this is what SVProgressHUD is doing. 至少这就是SVProgressHUD正在做的事情。

Here is some sample code 这是一些示例代码

if(!myView.superview){
    NSEnumerator *frontToBackWindows = [[[UIApplication sharedApplication]windows]reverseObjectEnumerator];

    for (UIWindow *window in frontToBackWindows)
        if (window.windowLevel == UIWindowLevelNormal) {
            [window addSubview:myView];
            break;
        }
}

The first line is to ensure that your view is not visible atm (maybe unnecessary in your context). 第一行是确保您的视图不可见atm(在您的上下文中可能是不必要的)。 To dismiss the view, remove it from its superview. 要关闭视图,请将其从其父视图中移除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM