Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your comment to Art's answer pretty much explains the problem. You have a button which is outside the visible area of its parent; it's irrelevant if the parent is positioned such that the button would be visible higher up on the stack. The button is getting clipped and not painted.</p> <p>You have two choices.</p> <p>1) Make myView's frame bigger and adjust all your coordinates appropriately. myView will always have some of its content offscreen and some onscreen and you can simply position it where you want. When the button is onscreen it will be visible. (E.g., in your code above the initial frame for myView would start at some negative value for x and extend to much wider than the iPhone screen, whereas your btn would be positioned at some positive x,y position relative to the top left of myView. Then you move myView so that, for example, it moves to 0,0, pushing some of its content offscreen while moving btn onscreen.)</p> <p>2) Don't put button on myView; put it on a new view that you animate <em>in</em> while you are animating myView <em>out</em>.</p> <p>Simple code for #1:</p> <pre><code>// Implement loadView to create a view hierarchy programmatically, without using a nib. - (void)loadView { UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(-100, 0, 420, 480)]; // start 100 pixels to the left UIButton *btn = [UIButton buttonWithType:UIButtonTypeContactAdd]; btn.frame = CGRectMake(0, 10, btn.bounds.size.width, btn.bounds.size.height); [myView addSubview:btn]; UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [btn1 setTitle:@"DoIt" forState:UIControlStateNormal]; btn1.frame = CGRectMake(100, 100, 50, 50); [btn1 addTarget:self action:@selector(doit:) forControlEvents:UIControlEventTouchUpInside]; [myView addSubview:btn1]; self.view = myView; } - (void) doit: (id) bt { [UIView beginAnimations:nil context:NULL]; self.view.frame = CGRectMake(100, 0, 420, 480); [UIView commitAnimations]; } </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.
    3. 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