我试图将用户发送到注册页面,如果他们还没有注册用户名等。我无法获得注册viewController加载,它只加载MainViewController。我已经尝试了我能找到的所有方法,但没有任何效果。我的背景是Java / Android,所以这一切都很新。正确方向的一点将非常感激..
码
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
BOOL hasRegistered = YES;
if (!hasRegistered)
{
UIViewController *viewController = [[UIStoryboard storyboardWithName:@"Main" bundle:NULL] instantiateViewControllerWithIdentifier:@"registrationView"];
[self presentViewController:viewController animated:YES completion:nil];
}
}
试试这个
registrationViewController *viewController = (registrationViewController*)[[UIStoryboard storyboardWithName:@"Main" bundle:NULL] instantiateViewControllerWithIdentifier:@"registrationView"];
代替
UIViewController *viewController = [[UIStoryboard storyboardWithName:@"Main" bundle:NULL] instantiateViewControllerWithIdentifier:@"registrationView"];
如果以模态方式显示视图控制器,则使用此命令打开
[self presentViewController:viewController animated:YES completion:nil];
或者如果你使用navigationController
那么
[self.navigationController pushViewController:viewController animated:YES];