IOS: open and close some view controllers

In my application, I have the following configuration to open my view controllers:

When I write "pushViewController" , I use the navigation controller, and when I write "present" , I use presentModalViewController .

 firtsView -> (pushviewcontroller) -> secondOneView -> (present) -> thirdOneView -> (present) -> fourthView firstView -> (pushviewcontroller) -> secondTwoView -> (present) -> thirdTwoView 

This is a diagram of my application for organizing my controllers. Then my question is:

How to return from the “fourth view” (ie when I return from the “fourth view” ) to “secondTwoView” ?

Is there any way to do this?

+4
source share
3 answers

Yes there is.

UIViewController offers various methods for rejecting the view controller, depending on whether you were represented by the method or not. It:

 -(void)dismissModalViewControllerAnimated:(BOOL)animated; // modal -(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion; 

You will need to fire them one by one. It also takes time to read Apple's View Programming Guide .

Using the UINavigationController , you can go to any view controller using:

 -(NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated; 

Alternatively, another way allows you only once:

 -(UIViewController *)popViewControllerAnimated:(BOOL)animated; 
+5
source

if you are using presentViewController

I think you need to disable viewController one by one

but if you are only a navigation controller, then you can put in the viewController you want

0
source
  • in viewOneView controller, do offsetModalViewControllerAnimated: NO
  • in secondOneView viewcontroller disable MommalViewControllerAnimated: NO again.
  • in secondOneView viewcontroller do popViewControllerAnimated: NO
  • in the first view, Viewcontroller do pushViewController on secondTwoView

If you need animation. I would suggest doing it manually using CoreAnimation. As

 -(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion; 

Available only after iOS5.

0
source

Source: https://habr.com/ru/post/1393332/


All Articles