Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think it would be best to use the custom container controller methods to do this. In the example code I have below, I made a login controller that was the size of a form sheet (540 x 600) and slid it in from the right onto the main view of ViewController so that it was centered vertically, and up against the right side. </p> <p>In ViewController.m, I have this:</p> <pre><code>-(IBAction)showLogin:(id)sender { LoginController *login = [self.storyboard instantiateViewControllerWithIdentifier:@"Login"]; login.view.frame = CGRectMake(768, 202, 540, 600);//centered vertically and offscreen to the right [self addChildViewController:login]; [self.view addSubview:login.view]; [UIView animateWithDuration:.5 animations:^{ login.view.frame = CGRectMake(228, 202, 540, 600); } completion:^(BOOL finished) { [login didMoveToParentViewController:self]; }]; } </code></pre> <p>And to remove the view, I have this in the LoginController.m:</p> <pre><code>-(IBAction)goBackToMain:(id)sender { [UIView animateWithDuration:.5 animations:^{ self.view.frame = CGRectMake(768, 202, 540, 600); } completion:^(BOOL finished) { [self.view removeFromSuperview]; [self removeFromParentViewController]; }]; } </code></pre> <p><strong>After Edit:</strong></p> <p>If you want to remove the login controller from a button in ViewController, you can do it like this:</p> <pre><code>-(IBAction)goBackToMain:(id)sender { LoginController *login = self.childViewControllers.lastObject; [UIView animateWithDuration:.5 animations:^{ login.view.frame = CGRectMake(768, 202, 540, 600); } completion:^(BOOL finished) { [login.view removeFromSuperview]; [login removeFromParentViewController]; }]; } </code></pre>
    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. 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