【问题标题】:Set a new window.rootViewController before the view gets loaded在视图加载之前设置一个新的 window.rootViewController
【发布时间】:2012-11-04 03:50:57
【问题描述】:

所以我想在我的应用中安装这个导航框架:

https://github.com/weissi/FRLayeredNavigationController

http://www.youtube.com/watch?v=k9bFAYtoenw&feature=plcp

现在,如果您查看所附图片,我有我的登录屏幕。登录完成后,我将 Segue Modal 推送到我的“主页”页面,在那里,我想在到达主页后开始使用 FRLayeredNavigationController。使用情节提要时可能吗?根据 Youtube 视频,通常会通过以下方式使用 FRLayeredNavigationController:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        // Override point for customization after application launch.

        HomeViewController* homeController = [[HomeViewController alloc] init];
        FRLayeredNavigationController* lnc = [[FRLayeredNavigationController alloc] initWithRootViewController:homeController];

        self.window.rootViewController = lnc;
    }



   [self.layeredNavigationController pushViewController:vc inFrontof:self maximumWidth:NO animated:YES];

【问题讨论】:

    标签: objective-c ios5 uiviewcontroller uinavigationcontroller ios6


    【解决方案1】:

    我还没有找到使用 Segue 的方法来做到这一点...但我完成此操作的方法如下:

    如果登录成功并且您想要进入应用程序的下一部分,那么您将如何转换:

    - (void)loginSucceeded
    {
        UIViewController * vc = (UIViewController*)[self.storyboard instantiateViewControllerWithIdentifier:@"someIdentifier"];
        FRLayeredNavigationController * nav = [[FRLayeredNavigationController alloc] initWithRootViewController:vc configuration:^(FRLayeredNavigationItem *item) {
            item.width = 300;
            item.nextItemDistance = 90;
        }];
        [self presentViewController:nav animated:YES completion:nil];
    }
    

    您需要将 Storyboard ID 设置为上述方法中指定的 ID。这可以在查看情节提要并选择您设计的 ViewController 时在“身份检查器”选项卡中找到。

    此外,您将不再需要执行之前创建的 segue,因此请删除它。

    您想在屏幕上“推送”任何未来的视图控制器,您只需调用以下代码:

    UIViewController * vc = (UIViewController*)[self.storyboard instantiateViewControllerWithIdentifier:@"SomeStoryboardIDHere"];
    [self.layeredNavigationController pushViewController:vc inFrontOf:self maximumWidth:YES animated:NO];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多