长按 UIButton [英] Long pressed UIButton
本文介绍了长按 UIButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如果有人按住 UIButton 键的时间过长,我是否可以捕获 UIButton 的事件(通过通知或其他某种机制);比按一次按钮还要长 - 假设有人按住按钮几秒钟......
I was wondering if I could capture an event (via Notification or some other mechanism), of a UIButton if somebody is holding the key pressing a UIButton for an excessive period of time; longer than a single button push - let's say somebody that holds the button pressed for a few seconds...
谢谢.
推荐答案
您可以添加 UILongPressGestureRecognizer
到您的按钮,在其 initWithTarget:action: 中传递一个选择器code>,并通过设置其
minimumPressDuration
属性来选择持续时间.
You can add UILongPressGestureRecognizer
to your button, pass a selector in its initWithTarget:action:
, and choose the duration time by setting its minimumPressDuration
property.
这篇关于长按 UIButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文