简体   繁体   English

iOS / xcode / objective-c:如何在注册后实例化视图控制器

[英]iOS/xcode/objective-c: How to instantiate view controller after signup

After a successful sign up, I want users to go through a process where they provide photo etc. Similar code to that below worked to load the login page but code below is not working to load a separate view controller in storyboard "newuser". 成功注册后,我希望用户经历一个提供照片等的过程。类似于下面的代码可用于加载登录页面,但下面的代码不适用于在故事板“ newuser”中加载单独的视图控制器。

Would appreciate any suggestions on how to fix. 将不胜感激有关如何修复的任何建议。

- (void)presentNewUserInterface
{
    UIViewController* rootController = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"newuser"];
    UINavigationController* navigation = [[UINavigationController alloc] initWithRootViewController:rootController];
    self.window.rootViewController = navigation;     
}

Two variants: 两种变体:

  1. Replace window.rootViewController with your next view controller. 用下一个视图控制器替换window.rootViewController Do it on AppDelegate class. 在AppDelegate类上执行此操作。

  2. Present new view controller from current root view controller. 从当前的根视图控制器呈现新的视图控制器。 Do it in your sign up view controller. 在您的注册视图控制器中执行此操作。

The lack of the first method is no transaction animation. 第一种方法的不足是没有交易动画。 So second method is preferable. 因此,第二种方法是可取的。

Instead of: 代替:

- (void)presentNewUserInterface
{
    UIViewController* rootController = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"newuser"];
    UINavigationController* navigation = [[UINavigationController alloc] initWithRootViewController:rootController];
    self.window.rootViewController = navigation;     
}

Try: 尝试:

- (void)presentNewUserInterface
{
    UIViewController* rootController = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"newuser"];
    UINavigationController* navigation = [[UINavigationController alloc] initWithRootViewController:rootController];
    [self presentViewController:navigation animated:YES completion:nil];    
}

You aren't presenting your new navigation controller in your example. 您没有在示例中展示新的导航控制器。 Is there a particular reason why you would be trying to replace your rootViewController? 有特定的原因为什么您要尝试替换rootViewController? That shouldn't be needed. 那不是必需的。 My example should be sufficient for displaying your next flow in the user sign up process. 我的示例足以显示用户注册过程中的下一个流程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS / objective-c / xcode:在代码中实例化DetailView控制器 - IOS/objective-c/xcode: Instantiate DetailView Controller in Code iOS / Objective-C:在SLComposer消息后关闭视图控制器 - IOS/Objective-C: Dismiss view controller after SLComposer message 如何在另一个视图控制器中控制对象? (Xcode:objective-c) - How to control objects in another view controller? (Xcode:objective-c) 如何从iOS Objective-C中的控制器重绘自定义视图 - how to redraw custom view from the controller in ios objective-c ios / xcode / objective-c:导航到嵌入在导航控制器中的模态视图控制器 - ios/xcode/objective-c: Segue to modal view controller embedded in navigation controller ios / xcode / objective-c:有什么方法可以链接到核心数据驱动页面中的其他视图控制器? - ios/xcode/objective-c: Any way to link to other view controller in core-data driven page? 如何在iOS上制作滑块音量控制器? Objective-C,iOS 7(或8),xcode 5(或6) - How to make a slider volume controller on iOS? Objective-C, iOS 7 (or 8), xcode 5 (or 6) iOS MMDrawerController Objective-C登录视图控制器 - iOS MMDrawerController objective-c login view controller iOS / objective-c:将对象传递到新的视图控制器 - iOS/objective-c: Pass object to new view controller iOS / Objective-C:在展示视图控制器中设置属性 - IOS/Objective-C: Set property in presenting view controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM