我有一个UIView
名为的属性viewToFade
,其中包含一个UISegmentedControl
. 当我为 设置动画时UIView
(因此它出现在点击并逐渐消失)时,UISegmentedControl
不响应触摸。这是我正在使用的代码:
-(void)fadeView
{
self.viewToFade.alpha=1;
self.viewToFade.hidden=NO;
//When I comment the following lines out, everything is fine--the `UISegmentedControl` responds as it should.
//But when I include them, the `UISegmentedControl` doesn't register changes/taps.
[UIView animateWithDuration:0.3
delay: 3.0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
self.viewToFade.alpha = 0.0;
}
completion:nil];
}
我究竟做错了什么?
(如果相关,我会说 theUIView
和 theUISegmentedControl
都是在 xib 文件中创建的。)
编辑:我想出了一种解决问题的方法,即重写代码如下:
-(void)fadeView
{
self.viewToFade.alpha=1;
self.viewToFade.hidden=NO;
[self performSelector:@selector(disneyfy) withObject:nil afterDelay:(3)];
}
-(void)disneyfy
{
[UIView animateWithDuration:0.3
animations:^{
self.viewToFade.alpha = 0.0;
}];
}