iphone - UILabel + touchDown

标签 iphone xcode ios4

是否可以实现UILabel的touchdown?

最佳答案

UILabelUIView 的子类,而 UIView 本身又是 UIResponder 的子类;因此,制作一个响应触摸的标签绝对是可能的。只需创建一个新的 UILabel 子类并实现以下方法:

– touchesBegan:withEvent:
– touchesMoved:withEvent:
– touchesEnded:withEvent:
– touchesCancelled:withEvent:

因此,如果您希望在触摸开始时发生某些事情,可以在 -touchesBegan:withEvent: 中执行。

如果创建一个新的子类对您来说太繁重,那么我建议按照 @JustSid 的建议进行操作,并使用 UIButton 来完成该任务。

关于iphone - UILabel + touchDown,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4158099/

相关文章:

iphone - 如何创建整数数组

iphone - Xcode:调试意外的 iOS 应用程序崩溃

iphone - UIWebView - 在 <img> 标签上启用操作表

objective-c - 'applicationDidBecomeActive' 之后调用了什么方法?

iphone - 在 iPhone 上崩溃,但在模拟器上没有崩溃

ios - 在 ScrollView : touchesBegan is received, 上拖动 View 但没有 touchesEnded 或 touchesCancelled

iphone - 如何锁定 UITable 以防止滚动超出表中的项目

objective-c - 在 setUp (Xcode) 中获取测试方法的名称

ios - HTTP 请求作为 iOS 中本地通知的后台任务

iphone - UIImagePNGRepresentation() 和比例(iPhone 4 屏幕)