Xcode - 切换视图控制器

时间:2014-08-21 21:59:06

标签: ios objective-c facebook

我已经实现了FacebookSDK以允许用户登录,并且我创建了一个名为“nextViewController”的新ViewController,并且在facebook auth完成后我不确定如何连接两者。根据文档,应该采用这种方法:

-(void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user{
    NSLog(@"%@", user);

在这个方法中,我如何转换到我的下一个视图“nextViewController”?

1 个答案:

答案 0 :(得分:1)

使用loginViewFetchedUserInfo您就在正确的轨道上...使用以下代码切换ViewControllers。

- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
                            user:(id<FBGraphUser>)user
{
    //use this if you're using storyboard. set storyboard ID to "next"
    nextViewController *nextView = [self.storyboard instantiateViewControllerWithIdentifier:@"next"];
    [self presentViewController:nextView animated:YES completion:^{
        }];

   //use this if you're using xib
   //Given that next.xib is the name of your xib file and nextViewController the name of your view controller class.
   nextViewController * nextView = [[nextViewController alloc] initWithNibName:@"next" bundle:nil];
   [self presentViewController:nextView animated:YES completion:^{
        }];


}