iOS   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 如何在应用程序启动时以模态方式呈现View Controller?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我创建了一个仅在我的应用首次启动时出现的屏幕;它很棒.但是,我想在我的根视图控制器上以模态方式显示此屏幕(EditorsNoteViewController是我想在首次启动时以模态方式呈现的屏幕).有谁知道我会怎么做?这是我到目前为止:

Appdelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
        {
            self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
            if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HasLaunchedOnce"])
            {
                NSLog(@"not first launch");

                      self.viewController = [[UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil] instantiateViewControllerWithIdentifier:@"articlesNav"];
                self.window.rootViewController = self.viewController;

            }
            else
            {
                [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"HasLaunchedOnce"];
                [[NSUserDefaults standardUserDefaults] synchronize];



                self.viewController = [[UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil] instantiateViewControllerWithIdentifier:@"articlesNav"];
                self.window.rootViewController = self.viewController;


     EditorsNoteViewController *vc = [[EditorsNoteViewController alloc]init];
             [self.viewController.navigationController presentViewController:vc animated:YES completion:nil];

}
                [self.window makeKeyAndVisible];
    return YES;
}

解决方法

我发现你必须打电话

[self.window makeKeyAndVisible];

在呈现视图控制器之前

大佬总结

以上是大佬教程为你收集整理的ios – 如何在应用程序启动时以模态方式呈现View Controller?全部内容,希望文章能够帮你解决ios – 如何在应用程序启动时以模态方式呈现View Controller?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: