Long and Short press on a UIBUTTON
-
18-03-2021 - |
문제
I need to implement long and short press for one button. how to go about with it. I implemented long press using longPressGestureRecognizer .. now i dont know how to do the same for short press.. its like for short press it has to load view1 and for long view2.
thank you.
해결책
By short press I assume you mean a tap on the button. If you are using a nib you can connect the button action event for touch or touch up inside to an IBAction. If not you can use addTarget:action:forControlEvents detailed here:
If you decide not to use a button or not to use the UIControl methods, you can attach a UITapGestureRecognizer to the same view with a different target action.
제휴하지 않습니다 StackOverflow