UIActivityIndicatorView 在 TransitionWithView 中出现后没有动画
我的主视图有一个子视图,其中有一个 UIActivityIndicatorView 。最初,该子视图的 hidden
属性设置为 YES
。
我希望这个子视图淡入屏幕上。我使用以下代码来实现此目的:
[UIView transitionWithView:self.view
duration:3.0
options:(UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction)
animations:^{
self.subviewWithActivitySpinnerInIt.hidden = NO;
}
尽管活动指示器设置为动画,但在使用上述代码出现后它不会动画。但是,如果我将上面的代码替换为下面的行(在完全相同的位置),那么当活动指示器出现时,它就会出现动画。
self.subviewWithActivitySpinnerInIt.hidden = NO;
知道发生了什么事吗?
(使用 Xcode 4.2 和 iOS 5。)
There is a subview of my main view, with a UIActivityIndicatorView in it. Initially the hidden
property of this subview is set to YES
.
I want this subview to fade onto the screen. I have used the following code to achieve this:
[UIView transitionWithView:self.view
duration:3.0
options:(UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction)
animations:^{
self.subviewWithActivitySpinnerInIt.hidden = NO;
}
Even though the activity indicator is set to animating, it doesn't animate after appearing with the above code. However if I replace the code above with the line below - in the exact same spot - then when the activity indicator appears it is animating.
self.subviewWithActivitySpinnerInIt.hidden = NO;
Any idea what's going on?
(Using Xcode 4.2 and iOS 5.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过将代码添加到完成块中?问题中缺少完成参数。
作为替代方案,尽管它可能不适合您的需求,但您可能需要考虑使用 animateWithDuration 而不是transitionWithView。我认为下面的代码是等效的:
Have you tried also adding the code to the completion block? The completion parameter is missing in the question.
As an alternative, though it may not be suited to your needs, you might want to consider using animateWithDuration instead of transitionWithView. I think the code below is equivalent: