Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I struggled with this one for a long time, and one of my issues is listed <a href="https://stackoverflow.com/questions/5913511/uiviewcontroller-resizing-itself-between-viewwillappear-and-viewdidappear">here</a>, I'm not sure if you have had that problem. But here's what I would recommend if it must work with iOS 4.</p> <p>Firstly, create a new <code>NavigationController</code> class. This is where we'll do all the dirty work--other classes will be able to "cleanly" call instance methods like <code>pushViewController:</code> and such. In your <code>.h</code>:</p> <pre><code>@interface NavigationController : UIViewController { NSMutableArray *childViewControllers; UIViewController *currentViewController; } - (void)transitionFromViewController:(UIViewController *)fromViewController toViewController:(UIViewController *)toViewController duration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL))completion; - (void)addChildViewController:(UIViewController *)childController; - (void)removeChildViewController:(UIViewController *)childController; </code></pre> <p>The child view controllers array will serve as a store for all the view controllers in our stack. We would automatically forward all rotation and resizing code from the <code>NavigationController</code>'s view to the <code>currentController</code>.</p> <p>Now, in our implementation:</p> <pre><code>- (void)transitionFromViewController:(UIViewController *)fromViewController toViewController:(UIViewController *)toViewController duration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL))completion { currentViewController = [toViewController retain]; // Put any auto- and manual-resizing handling code here [UIView animateWithDuration:duration animations:animations completion:completion]; [fromViewController.view removeFromSuperview]; } - (void)addChildViewController:(UIViewController *)childController { [childViewControllers addObject:childController]; } - (void)removeChildViewController:(UIViewController *)childController { [childViewControllers removeObject:childController]; } </code></pre> <p>Now you can implement your own custom <code>pushViewController:</code>, <code>popViewController</code> and such, using these method calls.</p> <p>Good luck, and I hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload