开发者

iOS UIView Transition, Container View Creation Issue

I've scoured blogs and Apple documentation and can't find an answer. Hope someone can lend their expertise.

I have a simple UIView animation that acts upon a container view 'gameContainer'. If I create this container view in a method called previously, all is well and good.

However, when I create 'gameContainer' immediately prior to the animation calls (code below) then the subView 'viewGrid' just appears without any animation effect.

-(IBAction) onInfoUp: (id) sender {
  //Add a container UIView for animation      
  [self.view addSubview:gameContainer]; // Moving this line to 'viewDidLoad' cures problem

 开发者_运维问答 //Call animation methods 
  [UIView beginAnimations:@"newGrid" context:nil];
  [UIView setAnimationDuration:1.3];
  [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft 
                       forView:gameContainer cache:YES];
  [gameContainer addSubview:viewGrid];
  [UIView commitAnimations];
}

I'm stumped as to why I must define the subview container in a separate method! Thanks in advance.


I believe this is due how UIKit updates the visual contents on the screen. All actual modifications to the screen happens at the end of the current run loop if it's running on the main thread, or at the end of the next run loop on the main thread otherwise. If you add gameContainer as shown in the code, it's not on the representation layer for the screen.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜