gpt4 book ai didi

ios - 如何在应用程序启动时以模态方式呈现 View Controller?

转载 作者:可可西里 更新时间:2023-11-01 04:34:38 25 4
gpt4 key购买 nike

我创建了一个仅在我的应用程序首次启动时出现的屏幕;它很好用。但是,我想在我的 Root 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];

在呈现 View Controller 之前

关于ios - 如何在应用程序启动时以模态方式呈现 View Controller?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25715957/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com