打开应用程序 3 次后显示 uialertview? [英] Show uialertview after opening an app after 3 times?

查看:22
本文介绍了打开应用程序 3 次后显示 uialertview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以说 3 次后打开应用程序时显示 Alertview 吗?这可以用 NSUserDefaults 来完成吗?

Is it possible to show a Alertview when opening an app after lets say 3 times? Can this be done with NSUserDefaults?

谢谢!

推荐答案

int launches = [[NSUserDefaults standardUserDefaults] integerForKey:@"launchCount"];
if (launches > 3) {
  UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"My Alert" 
                                                  message:@"Some message" delegate:nil
                                        cancelButtonTitle:@"OK" otherButtonTitles:nil];
  [alert show];
}
[[NSUserDefaults standardUserDefaults] setInteger:launches+1 forKey:@"launchCount"];

这篇关于打开应用程序 3 次后显示 uialertview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆