iphone - 在一定数量的启动后出现警报

标签 iphone objective-c uialertview alert

我正在研究这个想法,我希望在一定数量的应用程序启动后弹出 UIAlert(假设在 20 次启动后)。

并且会有 2 个按钮。一个将重置计数器,这将使警报在另外 20 次发射后出现。 还有一个按钮可以让它消失并且再也不会出现。

我该怎么做?

最佳答案

查看 NSUserDefaults 以存储应用程序启动的次数。

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
uint count = [defaults integerForKey:@"num_launches"];

if (count > 20) {
    // Show alert
} else {
   count ++;
   [defaults setInteger:count forKey:@"num_launches"];
}

关于iphone - 在一定数量的启动后出现警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5910443/

相关文章:

ios - UITableViewCell 选中行的文字颜色变化

ios - 在 Objective-C 中使用 JSON 中的 webService

objective-c - UIDatePicker Date 属性不会设置所选日期 - 而是给出当前日期

objective-c - 找不到体系结构 armv6 的符号

uialertview - 在 NSObject 中使用 UIAlertView

ios - 不区分大小写的SearchBar Xcode

iphone - iPad上的UIWebView初始化崩溃

iphone - "Blue box"显示在 iOS 应用程序中的自定义 UIButton 旁边

ios - 错误链接按钮

ios - 如何将带有文本的图像添加到 UIAlertView 中?