UISegmentedControl在UIView中没有响应

时间:2012-09-07 03:51:58

标签: iphone ios uisegmentedcontrol

我有一个名为UIView的{​​{1}}属性,其中包含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]; } UIView都是在xib文件中创建的。)

编辑:我找到了解决问题的方法,即按如下方式重写代码:

UISegmentedControl

1 个答案:

答案 0 :(得分:1)

我在一个示例项目中玩弄了这个并且可以复制你的结果 - 我甚至没有动画(在我的情况下)一个按钮本身使它不受触摸的影响。然而,在我的有限测试中,我能够看到它确实响应突出显示。

我刚刚测试了以下内容(使用UIBuutton,假设同样的东西适用于分段控制):

  • 在按钮上添加透明视图,并在动画之前添加手势识别器

  • 让点击识别器的actionMethod更改按钮的高亮显示,然后调度一个块以在100ms左右关闭它(如果你实际拦截触摸,你可能会变得更加漂亮)。

    < / LI>
  • 除了更改突出显示外,还可以向控件发送类似内容(再次使用按钮):

    [tapButton sendActionsForControlEvents:UIControlEventTouchUpInside];
    

在动画过程中,控件似乎对此类事物做出了响应。