pushviewcontroller在ios7中不起作用

时间:2014-01-06 21:43:52

标签: ios objective-c

第一次VC1到VC2 [self.navigationController pushViewController:mainView animated:YES]工作正常。从VC2到VC3在ios7中不起作用。

VC1-> VC2(正常工作)

- (IBAction)loginBtnAction:(id)sender
{

    GVMainViewController *mainView;
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
    {
        mainView = [[GVMainViewController alloc] initWithNibName:@"GVMainViewController_iPhone" bundle:nil];
    } else
    {
        mainView = [[GVMainViewController alloc] initWithNibName:@"GVMainViewController_iPad" bundle:nil] ;
    }

    [self.navigationController pushViewController:mainView animated:YES];
}

VC2-> VC3(工作无效)

- (IBAction)doneButtonAction:(id)sender
{
    [[FinishViewController getsharedInstance]updateProfileInfo];
    [self performSelector:@selector(moveTo) withObject:nil afterDelay:0.5];

}

- (void)moveTo
{
    GVMainViewController *mainView;
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
    {
        mainView = [[GVMainViewController alloc] initWithNibName:@"GVMainViewController_iPhone" bundle:nil];

    } else
    {
        mainView = [[GVMainViewController alloc] initWithNibName:@"GVMainViewController_iPad" bundle:nil] ;
    }

    [self.navigationController pushViewController:mainView animated:YES];
}

并获取一些日志在意外状态下完成导航过渡。在所有iOS版本中,导航栏子视图树可能已损坏。,但在ios7中,它没有推动视图控制器。

请任何人清楚地告诉我iOS7及更低版本的解决方案。在此先感谢。

1 个答案:

答案 0 :(得分:4)

当performSelector启动后台线程时,应该在主线程上推送mainView。

- (void)moveTo
{
    GVMainViewController *mainView;
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
    {
         mainView = [[GVMainViewController alloc] initWithNibName:@"GVMainViewController_iPhone" bundle:nil];

    } 
    else
    {
        mainView = [[GVMainViewController alloc] initWithNibName:@"GVMainViewController_iPad" bundle:nil] ;
    }

    dispatch_async(dispatch_get_main_queue(), ^{
        [self.navigationController pushViewController:mainView animated:YES];
    });
}