OGeek|极客世界-中国程序员成长平台

标题: iphone - iOS:有条件地加载 View Controller [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 22:41
标题: iphone - iOS:有条件地加载 View Controller

有没有办法从 App Delegate 有条件地加载 View Controller ?

例如,可以这样做吗?

    if (hasUserSignedUp) {
        nav = [[navController alloc] initWithNibName:nil bundle:nil];
        [window addSubview:nav.view];
        [window makeKeyAndVisible];
    }
    else {
        su = [[SignUpViewController alloc] initWithNibName:nil bundle:nil];
        [window addSubview:su.view];
        [window makeKeyAndVisible];
    }



Best Answer-推荐答案


是的,这很方便,您这样做没有任何限制。

但我认为你最好设置 rootViewController 而不是添加 View 。

self.window.rootViewController = nav;//or su;

关于iphone - iOS:有条件地加载 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10149592/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4