I have a bunch of UILabels that I add through code and I want to perform a specific action for each if the user's finger touches up inside (much like UIButton's touchUpInside in IB). What is the best way of doing this?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- how do you prevent page scroll in textarea on mobi
- Custom UITableview cell accessibility not working
相关文章
- Could I create “Call” button in HTML 5 IPhone appl
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- How do you detect key up / key down events from a
- “Storyboard.storyboard” could not be opened
- Adding TapGestureRecognizer to UILabel in Swift
- Open iOS 11 Files app via URL Scheme or some other
- Can keyboard of type UIKeyboardTypeNamePhonePad be
You can use UITapGestureRecognizer to perform action over the label Fields.
Set the number of taps and touches on the UITapGestureRecognizer object.
set user interaction of label field like
then add target method over the
The easiest way is probably to use UIButton instead of UILabel. A custom UIButton has no border and can look like a plain label, but handles the event tracking for you.
Otherwise, you must derive from UILabel and implement the UIResponder calls for touch handling.