UIActivityIndi​​cator没有动画

时间:2011-11-25 11:37:03

标签: objective-c ios multithreading

- (void) viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    self.connectionIndicator = [[[UIActivityIndicatorView alloc]
                                initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];
    [self.view addSubview:connectionIndicator];

    [self.connectionIndicator setCenter:CGPointMake(self.view.frame.size.width/2, 15)];
    [connectionIndicator startAnimating];
}

微调器显示为冻结,并且不会开始制作动画。

编辑:好的,我找出原因但尚未找到解决方案。

此视图控制器通过页面卷曲过渡推入导航控制器堆栈:

ServerHandshakeViewController *shvc = [[ServerHandshakeViewController alloc] initWithHost:h];
[UIView  beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[self.navigationController pushViewController:shvc animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
[shvc release];

如下所示删除上面的卷曲过渡解决了旋转器冻结问题。

ServerHandshakeViewController *shvc = [[ServerHandshakeViewController alloc] initWithHost:h];
[self.navigationController pushViewController:shvc animated:NO];
[shvc release];

但是,如果我想保留我的卷曲页面过渡怎么办?

1 个答案:

答案 0 :(得分:1)

您可以尝试使用块方法来指定动画选项。 UIViewAnimationOptionAllowAnimatedContent 是释放微调器的选项。

[UIView transitionWithView:self.navigationController.view 
                          duration:1.0 
                           options:UIViewAnimationOptionAllowAnimatedContent | UIViewAnimationTransitionCurlUp | UIViewAnimationOptionCurveEaseInOut 
                        animations:^{[self.navigationController pushViewController:shvc animated:NO];}
                        completion:nil];