gpt4 book ai didi

iphone - DidFinishLoading View 更改

转载 作者:行者123 更新时间:2023-11-28 19:13:14 25 4
gpt4 key购买 nike

我在应用程序中有一个登录屏幕 View 和 5 个选项卡。我希望当我完成登录屏幕时,它应该移动到选项卡 View (5)。为此,一旦登录任务完成,我必须删除 View 并添加选项卡的另一个 View Controller ......如何做到这一点......

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:self.viewController];


self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
return YES;
}

像这样我移动到登录 View ...现在如何在完成登录后删除并移动到 tab1,tab2,tab3,tab4,tab5

最佳答案

您可以在 AppDelegate 中创建以下方法以在 2 个导航 Controller 之间切换。

+ (AppDelegate *)sharedDelegate
{
return (AppDelegate *)[[UIApplication sharedApplication] delegate];
}

+ (void)showLogin {
AppDelegate *selfInstance = [self sharedDelegate];

self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:self.viewController];
selfInstance.window.rootViewController = nav;

}

+ (void)showTabs {
AppDelegate *selfInstance = [self sharedDelegate];

self.viewController2 = [[ViewController2 alloc] initWithNibName:@"ViewController2" bundle:nil];
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:self.viewController2];
selfInstance.window.rootViewController = nav;
}

您的 didFinishLaunchingWithOptions 方法应该如下所示:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

if( isLoggedIn ){
[AppDelegate showLogin];
} else {
[AppDelegate showTabs];
}

return YES;
}

然后在您应用的任何位置,您都可以:

[AppDelegate showTabs];

如果您在实现方面需要帮助,请告诉我。

关于iphone - DidFinishLoading View 更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13857676/

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