UISegmentedControl委托/触摸事件 [英] UISegmentedControl delegate/Touch Events

查看:102
本文介绍了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.

推荐答案

您可以将UISegmentedControl子类化,并覆盖- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { return; }方法来管理触摸的拖动和位置.

You could just subclass the UISegmentedControl and override - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { return; } 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.

这篇关于UISegmentedControl委托/触摸事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆