简体   繁体   中英

PushViewController doesn't pushes after dismissingViewController

I am developing iPhone app, where i got stuck at one point.

The error i am facing is, i have one presentViewController on which i have one button, on click of that button i am dismissing my presentViewController and after dismissing i want to push My view controller but it doesn't pushes.

Code on PresentViewController:

- (IBAction)ButtonClick:(id)sender {

    [self dismissViewControllerAnimated:YES completion:^{
        [Obj MethodCall];
    }];

} 

after dismissing PreviousViewController :

-(void) MethodCall
 {
    NSLog(@" -- MethodCall Success --");
    [self.navigationController pushViewController:[[NewViewController alloc] init] animated:YES];
 }

My log shows -- MethodCall Success -- but it does not pushes my view.

Where i am doing mistake ?

Please help and thanks for reading.

The problem with you is I think you are not having UINavigationController as a rootViewController of the viewController from which you have to navigate. So please try to add a UINavigationController as a parent view or rootView of the vieController from which you want to push another viewController.

 - (IBAction)ButtonClick:(id)sender {
    NewViewController *newView = [[NewViewController alloc] init]
       [self presentViewController:newView animated:YES completion:nil];
    } 

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