Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After some testing it appears that you cannot create the container view and set up the animation within the same runloop and have things work. In order to make your code work, I first created the <code>containerView</code> and the <code>redView</code> in the <code>viewDidLoad</code> method. Then I put your animation into the <code>viewDidAppear</code> method. So that I could reference the <code>containerView</code> and the <code>redView</code> from the <code>viewDidAppear</code> method, I made them properties. Here is the code for an <code>ST_ViewController.m</code> file that will perform the animation you wanted. </p> <pre><code>@interface ST_ViewController () @property (nonatomic, strong) UIView *containerView; @property (nonatomic, strong) UIView *redView; @end @implementation ST_ViewController - (void)viewDidLoad { [super viewDidLoad]; [self setContainerView:[[UIView alloc] initWithFrame:CGRectMake(10, 10, 300, 300)]]; [[self view] addSubview:[self containerView]]; [self setRedView:[[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)]]; [[self redView] setBackgroundColor:[UIColor redColor]]; [[self containerView] addSubview:[self redView]]; } -(void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; UIView *yellowView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)]; [yellowView setBackgroundColor:[UIColor yellowColor]]; [UIView transitionWithView:[self containerView] duration:3 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^(void){ [[self redView] removeFromSuperview]; [[self containerView] addSubview:yellowView]; } completion:nil]; } @end </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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