Calling popToRootViewControllerAnimated after dismissModalViewControllerAnimated

前端 未结 4 1470
孤独总比滥情好
孤独总比滥情好 2021-01-05 14:04

I am working application in which i calling presentModalViewController and once finished(calling dismissModalViewControllerAnimated:YES) it should

4条回答
  •  难免孤独
    2021-01-05 14:53

    Try something like this:

    [self.navigationController dismissModalViewControllerAnimated:YES] ;
    [self performSelector:@selector(patchSelector) withObject:nil afterDelay:0.3];
    
    
    -(void)patchSelector{
      [self.navigationController popToRootViewControllerAnimated:YES]; 
    }
    

    It is not so neat but it should work.

    UPDATE: You should use

     [self dismissModalViewControllerAnimated:YES];
    

    instead

     [self.navigationController dismissModalViewControllerAnimated:YES] ;
    

    The object that is presenting the modal is the view controller, not the navigation controller.

提交回复
热议问题