我知道有一百万个这样的问题,但解决方案对我不起作用。
每个人都在说,你需要推送到 ViewDidAppear 中的下一个 View Controller ,我就是这样做的,但仍然不起作用。
我正在使用 PARSE,并且根据用户登录时的说明 - 我想跳过登录屏幕并打开下一个。
这是我在 LoginViewController 中的代码。
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// Check if user is cached and linked to Facebook, if so, bypass login
if ([PFUser currentUser] && [PFFacebookUtils isLinkedWithUser:[PFUser currentUser]]) {
NSLog(@"Settings Screen should open automatically");
[self _presentUserSettingsSetupViewControllerAnimated:NO];
}
}
- (void)_presentUserSettingsSetupViewControllerAnimated:(BOOL)animated {
NSString * storyboardName = @"Main_iPhone";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
UserSettingsSetupViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"UserSettingsSetup"];
[self presentViewController:vc animated:animated completion:nil];
}
我看到了日志消息,但另一个 View Controller 没有打开 - 我仍然停留在登录 View Controller 中。
最佳答案
您在 viewDidAppear:
中呈现 View Controller ,但您发布的代码在 viewWillAppear:
中呈现 View Controller 。
View Controller 尚未呈现的 WILL 与 View Controller 已呈现的 DID 之间存在差异。
关于ios - 警告 : Attempt to present on whose view is not in the window hierarchy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26078198/