Dismissing both UINavigation views and Modal views at once programmatically

后端 未结 3 1082
梦毁少年i
梦毁少年i 2020-12-01 17:47

I have tried a few answers on this site, but none of them seem to relate to my problem

I have a MasterDetail app which has a two types of segues that I am using. Whe

3条回答
  •  有刺的猬
    2020-12-01 17:52

    From the class you presented your modal view

    call dismiss of modal and then perform selector after some delay and then do the

    here is the sample code

    //Write this in the class from where you presented a modal View.
    //Call the function from modal class when you want to dismiss and go to root.
    - (void) dismissAndGoToRoot {
          [self dismissViewControllerAnimated:YES completion:nil];
          [self performSelector:@selector(gotoRoot) withObject:nil afterDelay:0.50];
    }
    
    - (void)gotoRoot {
    
        [self.navigationController popToRootViewControllerAnimated:NO];
    }
    

    Here you will call the function

    //right here is where I would normally dismiss the modal VC //here is where I would like to dismiss all VC

    [self.parentViewController dismissAndGoToRoot];
    

    If this does not work then take an instance variable of ParentViewController in modal class and assign when presenting modal view controller.

提交回复
热议问题