【问题标题】:UIButton select on slide overUIButton 在滑动时选择
【发布时间】:2013-12-02 15:02:36
【问题描述】:

我在 UITableViewCell 中有这个自定义元素,它是由一个上面有 4 个按钮的图像组成的。 http://imgur.com/K8BF83O

现在我正在使用按钮上的 TouchUpInside 操作来处理选择,但我希望用户能够通过触摸滑动它,这样感觉就像你拿起“滑块”然后从 ++ 中移动它以 - 例如。
这意味着我想捕捉用户当前滑过的按钮以使该 UIButton 处于选定状态。

我尝试使用来自:How to create buttons which are activated when the user slides their finger over them on iPhone 的 touchBegan 方法。但 UITouch 似乎总是为零。
我做错了什么还是我忘记了什么?

你们对如何实现这种行为有任何提示吗?

提前致谢!

编辑:
我最终使用了平移、点击和长按手势识别器。
随着touchesbegin和touches结束。
这非常有效,我向所有遇到类似问题的人推荐它!

【问题讨论】:

  • 您是否尝试过使用“Touch Drag Enter”操作?有一大堆可能会起作用.. Look at the Apple Docs
  • 我刚刚尝试过调用这个方法:[self deselectButtons]; ((UIButton*)sender).selected = YES;但是 UI 不会更新,直到我“润色”然后按钮在我开始的地方被选中。

标签: ios objective-c uibutton


【解决方案1】:

为了你的目的,使用- (void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event方法还不够当用户在屏幕上移动手指时,-(void)touchesMove:(NSSet *)touches withEvent:(UIEvent *)event方法被调用。尝试使用这两种方法来检测触摸位置。

【讨论】:

  • 我明天试试这个!如果这有效,我会更新!谢谢
猜你喜欢
  • 2013-10-27
  • 2013-05-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-23
  • 1970-01-01
  • 2014-12-05
相关资源
最近更新 更多