【问题标题】:Make a UIAlertView show after second launch在第二次启动后显示 UIAlertView
【发布时间】:2012-06-18 04:33:51
【问题描述】:

如果这不可能,那么在使用应用程序 3 分钟后,我该怎么做?这将用于给我们评分提醒,但我希望用户在要求他们评分之前有一些时间实际使用该应用程序。

【问题讨论】:

    标签: ios xcode uialertview


    【解决方案1】:
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)options {
        // ...
        if ([self plusPlusLaunchCount] == 2) {
            [self showRateUsAlert];
        }
        return YES;
    }
    
    - (void)showRateUsAlert {
        // show the Rate Us alert view
    }
    
    - (NSInteger)plusPlusLaunchCount {
        static NSString *Key = @"launchCount";
        NSInteger count = 1 + [[NSUserDefaults standardUserDefaults] integerForKey:Key];
        [[NSUserDefaults standardUserDefaults] setInteger:count forKey:Key];
        return count;
    }
    

    【讨论】:

    • 这会出现在我的 appdelegate 中还是仅出现在第一个视图中?
    • application:didFinishLaunchingWithOptions:UIApplicationDelegate 消息。
    • 啊我现在明白了,假设我应该查看我的 AppDelegate。谢谢。
    • 它抛出了这个警告,有什么需要注意的吗?:在实现“应用程序:didFinishLaunchingWithOptions:”时返回类型冲突:“BOOL”(又名“签名字符”)与“无效”
    • 糟糕。将其更改为返回 BOOL,并返回 YES。
    【解决方案2】:

    您为什么不使用第三方库来提醒自己“评价我们”呢?反正这种事情已经做过很多次了。

    这是一个非常好的之一:iRate

    标题中没有完全回答您的问题。

    【讨论】:

      【解决方案3】:

      您需要为要显示警报的时间间隔设置NSTimer。当应用程序启动时启动计时器并在您设置的时间间隔结束后显示警报。

      【讨论】:

        【解决方案4】:

        我建议你使用 DidBecomeActive 每次启动应用程序时都会调用它,并且来自后台/睡眠模式:

        如果用户长时间不使用应用程序,您需要取消计时器。

        - (void)applicationDidBecomeActive:(UIApplication *)application{
            // Override point for customization after application launch.    
        
            rateUsTimer = [[NSTimer scheduledTimerWithTimeInterval:180 
                                             target:self
                                           selector:@selector(showRateUsAlert) 
                                           userInfo:nil 
                                            repeats:NO] retain];
        
        
        }
        
        - (void)applicationWillResignActive:(UIApplication *)application{
           [rateUsTimer_ invalidate];
           [rateUsTimer_ release];
           rateUsTimer = nil;
        }
        
        - (void)applicationDidEnterBackground:(UIApplication *)application{
           [rateUsTimer_ invalidate];
           [rateUsTimer_ release];
           rateUsTimer = nil;
        }
        
        
        - (void)showRateUsAlert {
            //Here you present alert
            [rateUsTimer_ release];
            rateUsTimer = nil;
        }
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2012-02-20
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多