Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For composing modal view controllers, you have two real options (ignoring cool stuff under NDA):</p> <ol> <li><p>Use the <a href="http://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html#//apple_ref/doc/uid/TP40007457-CH18-SW6" rel="nofollow">Container View Controller pattern</a> to insert the inner view controller into its parent.</p></li> <li><p>Add a new window with that view controller, similar to how you would do it in your AppDelegate. Create the window, add your child as a root view controller, make it key and visible. This is actually what <code>UIAlertView</code> does to perform a similar behavior to your app.</p></li> </ol> <p>I can't say what would be better for your case, but I have more experience with container view controllers so I'll give you the highlights. To add a child view you will need these steps (from the link above) in your parent view controller:</p> <pre><code>- (void) displayContentController: (UIViewController*) content; { [self addChildViewController:content]; // 1 content.view.frame = [self frameForContentController]; // 2 [self.view addSubview:self.currentClientView]; // 3 [content didMoveToParentViewController:self]; // 4 } </code></pre> <p>This will:</p> <ol> <li>Add your child view controller.</li> <li>Set the frame to whatever you want. This could be <code>self.view.bounds</code> if you want it to take up the full space.</li> <li>Add the view to its parent.</li> <li>Notify the child view controller that it was added.</li> </ol> <p>To remove a child view controller you would do the opposite, again from the link:</p> <pre><code>- (void) hideContentController: (UIViewController*) content { [content willMoveToParentViewController:nil]; // 1 [content.view removeFromSuperview]; // 2 [content removeFromParentViewController]; // 3 } </code></pre> <p>This will:</p> <ol> <li>Notify your child view controller that it will disappear.</li> <li>Remove its view from the visual stack.</li> <li>Remove it from its parent.</li> </ol>
    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