UISegmentedControl 委托/触摸事件
我有一个 UISegmentedControl,它有六个段,我希望它们在值更改时调用一个方法,而且当每个段获得 UIControlEventTouchDragIn 时也调用一个方法,因为我希望 UILabel 在该人时显示其名称正在尝试选择其上的某些内容并将手指拖过控件,但即使当我拖入该内容时,分段控件也不会发送此调用。请帮忙。也许我需要在控件上创建 UIButtons,在拖入时调用方法,但在收到点击时调用值更改方法。
I have a UISegmentedControl that has six segments, I want them to call a method when the value changes, but also when each segment gets a UIControlEventTouchDragIn
because I want a UILabel to show up with it's name when the person is trying to select something on it and drags their finger across the control, but the segmented control does not sen this call even when I drag into the thing. Please help. Maybe I need to create UIButtons over the control that call methods upon a drag in, but call the value changed method when they recieve a tap.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许我没有正确理解你的问题,但你不能只使用这个:
并用 UIControlEventTouchDragIn 替换 UIControlEventValueChanged 吗?然后在您的操作方法中执行任何需要执行的操作,例如更改 UILabel 的文本。
我有一个带有一堆单元格的 UITAbleView 和每个单元格中的 UISegmentedControll ,它对我来说工作得很好。
UISegmentedControl 的文档似乎无法在线获取,但您可以在 XCode 的 Organizer 中看到它,上面的代码是第一个示例。
Maybe I don't understand your question correctly but couldn't you just use this:
and just replace the UIControlEventValueChanged by UIControlEventTouchDragIn? Then in your action method do whatever needs to be done such as changing the text of a UILabel.
I have a UITAbleView with a bunch of cells and an UISegmentedControll in each cell and it works just fine for me.
The documentation for UISegmentedControl seems to be unavailable online but you can see it in XCode's Organiser and the code above is the first example.
您可以仅对 UISegmentedControl 进行子类化并重写
方法来管理触摸的拖动和位置。
由于无论如何您都无法判断拖动是在哪个部分,因此您最好通过触摸手动完成所有操作并使用这些功能跟踪它。
You could just subclass the UISegmentedControl and override
method to manage the dragging and location of the touches.
Being that you wouldn't be able to tell which segment the drag is on anyway, it might be better for you to do everything manually with touch and track it using those functions.