简体   繁体   中英

pushviewcontroller is not working in ios7

first time VC1 to VC2 [self.navigationController pushViewController:mainView animated:YES] is working fine. From VC2 to VC3 is not working in ios7.

VC1->VC2 (working fine)

- (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 (NOt working)

- (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];
}

and also getting some log Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted. in all iOS versions, But In ios7 it is not pushing the view controller.

Please any one tell me the solution clearly for iOS7 and lower versions. Thanks in Advance.

mainView should be pushed on main thread as performSelector initiates background thread.

- (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];
    });
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM