I'm a newbie of xcode and i have a question. I want to create a facebook login application, but i have a problem when i want to navigate from mainView to loginViewControl. I have found, tried, and tried but I have no solutions.
http://www.mediafire.com/convkey/2e63/7p37k32d13xs2zkfg.jpg
When the app starts, FB will check for session, if a session is cached, the MainTabBarController will load without problems. But I can't navigate the app to the LoginUIViewController when no session is cached. I put my (void)pushToLoginView function in to .m file of MainTabBarController but I tried many ways and it not works Here is the code of the MainTabBarController.m
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if (FBSession.activeSession.state != FBSessionStateCreatedTokenLoaded) {
[self pushToLoginView];
}
}
- (void)pushToLoginView {
LoginUIViewController *loginView = [[LoginUIViewController alloc] init];
[self presentViewController:loginView animated:YES completion:nil];
}
The error is:
2014-03-21 21:44:53.367 FB Media[5815:60b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<LoginUIViewController 0xa56ee70> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key nameLabel.'
UPDATE 1: I edited my function pustToLoginView like this:
- (void)pushToLoginView {
LoginUIViewController *loginView;
self.view = loginView.view;
}
And it's worked, but the loginView's brank new and have nothing (loginButton didn't appear). So I think i have a problem when connected from code to UserInteface. So please have me!
you should load LoginUIViewController from storyboard
LoginUIViewController *viewController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginUIViewController"];
check this Instantiate a view controller using a storyboard identifier
create a View Controller defined in you your Storyboard programmatically