iphone - 每次打开我的应用程序时打开 View ,仅当用户选择时

标签 iphone ios objective-c

我正在为 iOS 编写游戏,我想知道如何在每次打开应用程序时都打开指令 View Controller 。我想要一个开关,上面写着“每次都给我看这个”。如果他们将其切换为否,则在打开应用程序时将不再显示说明。

最佳答案

您可以使用 NSUserDefaults存储开关值,然后在每次应用程序启动时在您的应用程序委托(delegate) applicationDidBecomeActive 方法中检查它。

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
   BOOL switchState = [[NSUserDefaults standardUserDefaults] boolForKey:@"switchKey"];
   if(switchState) {
       //If switch is on create the instance of InstructionViewController
       //you can call any of InstructionViewController methods on it.
       InstructionViewController* intructionsViewController = [[InstructionViewController alloc] init];
       //Present the instance of instruction view on top of your current view
       [self.window.rootViewController presentViewController:controller animated:YES completion:nil];
   }
}

关于iphone - 每次打开我的应用程序时打开 View ,仅当用户选择时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15526090/

相关文章:

ios - 如何在调用某人时删除 iOS 应用程序中的弹出窗口?

iphone - 在二进制中查找类符号的来源

ios - NSURLSessionDownloadTaskDelegate JSON 响应

ios - 当使用动画 block 内函数的参数时,Swift 无法解析 UIView.animateWithDuration 中的 CurveEaseIn

ios - 为什么使用新的 iOS 7 API 扫描条形码真的很慢?

ios - Monotouch Dialog 杀死了我的 UINavigationController 后退按钮

ios - 监听 url 并重定向

iphone - UITableViewController 中的静态单元格在同一 Nib 上打开不同的 URL

iphone - 是否可以在不辞去第一响应者的情况下使 iPhone 键盘隐形/将其删除?

objective-c - NSMutableDictionary 添加子项