首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >试图在过渡过程中开始模式转换

试图在过渡过程中开始模式转换
EN

Stack Overflow用户
提问于 2014-02-22 17:49:55
回答 1查看 115关注 0票数 0

我正在检查用户是否登录到Facebook。如果是的话,我想把它们转移到另一个视图。

我遇到的问题是,在视图实际加载之前,loginViewFetchedUserInfologinViewShowingLoggedInUser都会被调用。

正因为如此,当调用[self showWelcome:self]时,我得到一个“试图在转换过程中开始模态转换”错误()。

在将视图发送到新视图之前,我似乎想不出一种等待视图完成加载的方法。

代码语言:javascript
复制
- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView {

    // Set flag
    isFirstLoginDone = YES;

    NSLog(@"User is logged in");
}

- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
                        user:(id<FBGraphUser>)user {

    // Check first login
    if(isFirstLoginDone) {
         [self showWelcome:self];
    }

    // clear the flag
    isFirstLoginDone = NO;

}

- (IBAction)showWelcome:(id)sender
{
    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"WelcomeStoryboard" bundle:nil];
    UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"WelcomeController"];
    [self presentViewController:vc animated:YES completion:nil];
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-22 17:58:43

是的,当您在出现一个viewController时,出现了另一个viewController。为此,按照下面的代码创建一个虚拟方法,并以较小的时间间隔启动它。

代码语言:javascript
复制
- (IBAction)showWelcome:(id)sender{
   [self someMethod];
}

-(void)someMethod{
    if(self.isBeingPresented){
        [self performSelector:@selector(someMethod) withObject:nil afterDelay:.1];
    }
    else{
        UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"WelcomeStoryboard" bundle:nil];
        UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"WelcomeController"];
        [self presentViewController:vc animated:YES completion:nil];
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21958026

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档