bratboy
bratboy

Reputation: 3

UIView controls not drawing until animation completes

I have a fairly simple app with two UIViewControllers. One is the main view, the second is an options page. When I animate from one to the other, the UISwitches and other controls don't fully draw until after the rotation completes. If I don't use an animation, then there isn't a problem - everything appears correctly. Here's the code:

[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

if (self.optionsViewController.view.superview == nil)
{
    if (self.optionsViewController == nil)
    {
        self.optionsViewController = [[OptionsViewController alloc] initWithNibName:nil bundle:nil];
    }
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];

    [self.view insertSubview:self.optionsViewController.view atIndex:127];
}

[UIView commitAnimations];

Upvotes: 0

Views: 123

Answers (1)

Ryan Poolos
Ryan Poolos

Reputation: 18551

Have you tried setting cache to NO? Caching saves the views as rasterized forms which is probably happening mid draw for the subviews of the OptionsViewController.

Also you should consider using the much newer and better animation methods with iOS5.

+ (void)transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion

Upvotes: 2

Related Questions