1

On iOS, a UIButton can use addTarget to specify a method to call when the button is tapped on, but what about UILabel, is there something similar, or is the only option using UITapGestureRecognizer?

nonopolarity
  • 146,324
  • 131
  • 460
  • 740
  • The question is answered here: http://stackoverflow.com/questions/3269385/programmatically-perform-an-action-on-uilabel-touchupinside – Ben-G Jul 19 '12 at 12:13

2 Answers2

1

addTarget:action:forControlEvents: is a method of UIControl class. UIButton is a subclass of UIControl but not UILabel. So yes a tap gesture is the better way.

iSofTom
  • 1,718
  • 11
  • 15
0

Please see this question for the answer.

UILabel inherits from UIView which inherits from UIResponder. All UIresponder objects can handle touch events.

Community
  • 1
  • 1
Joshua Kaden
  • 1,210
  • 11
  • 16