我正在我的iOS应用中集成Twitter应用。问题是在成功登录后,应该控制到特定视图控制器的segue返回到我的登录页面而不是返回到所需的视图控制器。已经执行了segue,我可以在输出控制台中看到它。有线的事情是,当我点击登录页面上的推文按钮时,segue最终在视觉上第二次执行。
我的推特登录方法如下:
- (IBAction)tweetbutton:(id)sender {
[SCTwitter initWithConsumerKey:@"your_consumer_key" consumerSecret:@"your_consumer_secret"];
[SCTwitter loginViewControler:self callback:^(BOOL success){
NSLog(@"Login is Success - %i", success);
if (success) {
[self performSegueWithIdentifier:@"authentication" sender:self];
}
}];
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
NSLog(@"prepareForSegue: %@", segue.identifier);
}
控制台中的输出是:
2014-12-10 23:54:16.923 gems[1300:60b] Login is Success - 1 2014-12-10 23:54:16.946 gems[1300:60b] prepareForSegue: authentication
我不明白我错在哪里以及为什么segue在登录成功时无法自动显示。请建议一个合适的解决方案,以便直接自动转换到特定的视图控制器,而无需再次返回登录页面,同时根据您的知识,我使用的是普通视图控制器,而不是导航控制器。
提前致谢。任何帮助将不胜感激。
答案 0 :(得分:0)
使用Swift 3:
在 viewDidLoad():
中使用此功能Twitter.sharedInstance().logIn { (session, error) in
if error == nil {
performSegue(withIdentifier: "authentication", sender: self)
}
}