开发者

Animation doesn't start without view update

Sample on GitHub

I have a strange problem.

I have Navigation-based app with two UIViewControllers and Curl effect for transition between these.

I add to bar button and add custom action:

-(IBAction)pushPage
{
    NSLog(@"push page");
    SecondViewController *secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
    [UIView beginAnimations:@"animation" context:nil];
    [UIView setAnimationDuration:0.75];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:NO];
    [self.navigationController pushViewController:secondView animated:NO];
    [UIView commitAnimations];  
    [secondView release];
}

In SecondView I have a button with action:

-(IBAction)back
{
    [imageAnimationIssueAppDelegate backPage];
}

Method backPage in AppDelegate:

-(void)backPage
{
    NSLog(@"backPage");
    [UIView beginAnimations:@"animation" context:nil];
    [UIView setAnimationDuration:0.75];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.navigationController.view cache:NO];
    [self.navigationController popToRootViewControllerAnimated:NO];
    [UIView commitAnimations]; 
}

PROBLEM: On the RootView I have UIImageView with animation:

- (void)viewDidLoad
{
    [super viewDidLoad];

    animImage.animationImages = [NSArray arrayWithObjects:
                             [UIImage imageNamed:@"1.png"],
                             [UIImage imageNamed:@"2.png"],
                             [UIImage imageNamed:@"3.png"],
                             [UIImage imageNamed:@"4.png"],                                 
                             [UIImage imageNamed:@"3.png"],
                             [UIImage imageNamed:@"2.png"],
                             nil];
    animImage.animationDuration = 0.5;
    animImage.animationRepeatCount = 0;
}

I start it in viewDidAppear:

- (void)viewDidAppear:(BOOL)animated
{
    NSLog(@"First view - viewDidAppear");
    [super viewDidAppear:animated];
    [animImage startAnimating];
}

I stop it in viewDidDisapear:

- (void)viewDidDisappear:(BOOL)animated
{
    NSLog(@"First view - viewDidDisappear");
    [super viewDidDisappear:animated];
    [animImage stopAnimating];    
}

When I back from SecondView animation is stoped! But [animImage isAnimating] say YES! It doesn't start witout update screen - you can click to button on the bottom and see it!

Is it bug?

Animation works without custom transitions.

When I set animated:YES for push or pop view, animation works with custom transitions between views.

Why? Is there simple way to u开发者_如何学编程pdate displaying view to start animation?


I think you should have to write

 [yellowBatterfly startAnimating]; 

in viewDidLoad method. and change method from

viewDidAppear to viewWillAppear and

viewDidDisappear to viewWillDisappear.

Hope It will works...


I think you have to perform the animations on the view using:

[UIView commitAnimations]
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜