刚开始使用Xcode 4.5,我在控制台中遇到了这个错误:
警告:尝试在<ViewController:0x1ec3e000>上显示<finishViewController:0x1e56e0a0>,其视图不在窗口层次结构中!
该视图仍在呈现中,应用程序中的所有内容都正常运行.这是iOS 6中的新功能吗?
这是我用来在视图之间切换的代码:
UIStoryboard *storyboard = self.storyboard;
finishViewController *finished =
[storyboard instantiateViewControllerWithIdentifier:@"finishViewController"];
[self presentViewController:finished animated:NO completion:NULL];
Run Code Online (Sandbox Code Playgroud) 我正在做Facebook集成教程,如果用户有当前状态的有效令牌,我想显示我的MainViewViewController,否则我想显示LoginViewController.
MainViewAppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {
// To-do, show logged in view
} else {
// No, display the login page.
[self showLoginView];
}
return YES;
}
- (void)showLoginView
{
UIStoryboard *mainstoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
LoginViewController* loginViewController = [mainstoryboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
[self.window.rootViewController presentViewController:loginViewController animated:YES completion:NULL];
}
Run Code Online (Sandbox Code Playgroud)
控制台错误:
Warning: Attempt to present <LoginViewController: 0xb492fd0> on <MainViewViewController: 0xb1bd820> whose view is not in the window hierarchy!
Run Code Online (Sandbox Code Playgroud)
我不想使用NavigationController.
ios6 ×2
appdelegate ×1
cocoa-touch ×1
facebook ×1
hierarchy ×1
ios ×1
objective-c ×1
views ×1
xcode ×1