gpt4 book ai didi

ios在运行时更改 Storyboard默认 View Controller

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

是否可以覆盖 Storyboard中的默认 View Controller 以显示不同的 Controller ?当然,这一切都将发生在 AppDelegate 中。

最佳答案

@Martol1ni 我想使用你的答案,但我也想避免不必要的 Storyboard困惑,所以我稍微调整了你的代码。但是,我确实给了您鼓舞人心的答案 +1。

我将以下所有内容放在默认 Controller 上。

- (void)gotoScreen:(NSString *)theScreen
{
AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];

UIViewController *screen = [self.storyboard instantiateViewControllerWithIdentifier:theScreen];
[app.window setRootViewController:screen];
}

然后在逻辑发生的地方我将根据需要调用以下内容。

if(myBool == YES) {
[self gotoScreen:@"theIdentifier"];
}

关于ios在运行时更改 Storyboard默认 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10610012/

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