问题描述
我有以下代码块淡出introView(UIView)
I have the following block of code to fade out an introView(UIView)
// Hide intro view after 5 seconds
[UIView animateWithDuration: 1.0
delay: 5.0
options: (UIViewAnimationOptionAllowUserInteraction |UIViewAnimationOptionCurveLinear)
animations: ^{
introView.alpha = 0;
}
completion: ^(BOOL finished) {
[introView removeFromSuperview];
}];
我在introVew中有一个跳过按钮,但没有任何交互,我错过了什么?我必须添加这是一个针对3.2的通用应用程序,我正在使用XCode 4.2
I have a skip button inside the introVew but there is no interaction whatsoever, am I missing something? I have to add this is a Universal app targeting 3.2 and I'm using XCode 4.2
推荐答案
您是否将按钮alpha设置为0?
如果是,这里有一个关于动画的有趣的事情。
Are you setting your button alpha to 0?
If yes here is an interesting thing about animation.
动画期间在屏幕上看到的内容不是应用程序看到的内容。
当你将alpha设置为0时,即使你仍然在屏幕上看到它,该视图的alpha为0。
另外,一个alpha低于0.05的视图(不记得确切的数字)不会得到触摸事件。
What you see on the screen during the animation is not what the application sees.The moment you set your alpha to 0, the alpha is 0 for that view, even if you are still seeing it on the screen.
Also, a view that has an alpha lower that 0.05 (don't recall the exact number) won't get touch event.
你可以做的是实现 - (void)touchesBegan :(NSSet *)触及该视图的superview的事件:(UIEvent *)事件
。或者 touchesEnded ...
如你所愿。
(假设你没有将它的alpha设置为0。)
What you can do is to implement the - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
of that view's superview. or the touchesEnded...
as you like.
(Assuming that your not setting it's alpha to 0.)
因此,您可以测试按钮所在的触摸,或者只是删除该按钮,让屏幕上的任何触摸取消动画。
So you can test for touche that occur where the button is, or just remove that button and let any touch on the screen cancel your animation.
您可能还对这篇文章感兴趣:
You may also be interested in this post:
Core Animation, unexpected animated position and hitTest values
这篇关于在UIView动画中遇到允许交互的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!