1
這是一個2部分問題。將Facebook登錄信息傳遞給第二個視圖
1.)一旦用戶登錄到應用程序,我想導航到DashboardViewController
。但是,我最後會發出警告。
警告:嘗試在其針對目前 不在窗口 層次!
如何解決這個問題?
2.)我想通過(id<FBGraphUser>)user
到DashboardViewController
,我該怎麼做到這一點?
的代碼如下:
-(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
無法添加Segue公司,因爲它不是一個UIButton,但一個視圖已經到位。 – Illep
@Illep嗨。您應該能夠從您的原始視圖控制器添加一個segue到您的儀表板視圖控制器,您的案例(我想)從VC提示登錄儀表板VC。您的登錄控制器肯定有辦法確定登錄事件成功完成的時間,並且在那裏您可以觸發performSegueWithIdentifier方法。 –
是的,我嘗試過。但是,我仍然得到相同的警告。 – Illep