This is a 2 part question.
1.) Once the user login to the application i want to navigate to DashboardViewController. However, i am ending up with a warning.
Warning: Attempt to present on whose view is not in the window hierarchy!
How to solve this?
2.) I want to pass (id<FBGraphUser>)user to the DashboardViewController, How can i achieve this?
The code is as follows:
-(void)viewWillAppear:(BOOL)animated{
//[self toggleHiddenState:YES];
self.lblLoginStatus.text = @"";
self.loginButton.delegate = self;
self.loginButton.readPermissions = @[@"public_profile", @"email"];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Private method implementation
-(void)toggleHiddenState:(BOOL)shouldHide{
self.lblUsername.hidden = shouldHide;
self.lblEmail.hidden = shouldHide;
self.profilePicture.hidden = shouldHide;
}
#pragma mark - FBLoginView Delegate method implementation
-(void)loginViewShowingLoggedInUser:(FBLoginView *)loginView{
self.lblLoginStatus.text = @"You are logged in.";
[self toggleHiddenState:NO];
}
-(void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user{
NSLog(@"%@", user);
self.profilePicture.profileID = user.objectID;
self.lblUsername.text = user.name;
self.lblEmail.text = [user objectForKey:@"email"];
//
[self performSelector:@selector(displayDashboard) withObject:nil afterDelay:0.5];
}
-(void)displayDashboard{
DashboardViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"DashboardSegue"];
[[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentViewController:vc animated:YES completion:nil];
}
-(void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView{
self.lblLoginStatus.text = @"You are logged out";
[self toggleHiddenState:YES];
}
-(void)loginView:(FBLoginView *)loginView handleError:(NSError *)error{
NSLog(@"OKKKKK %@ ", [error localizedDescription]);
}
@end
Aucun commentaire:
Enregistrer un commentaire