0

I have a UILabel, and what I want is that when a user clicks that UILabel then the UIDatePicker would open.

Any idea how to do this?

Toon Krijthe
  • 52,876
  • 38
  • 145
  • 202
  • possible duplicate of [Display datepicker on tapping on textfield](http://stackoverflow.com/questions/6074683/display-datepicker-on-tapping-on-textfield) – HDdeveloper Jun 28 '13 at 09:28

5 Answers5

1

use should use UITapGestureRecognizer to create tap event in UILabel

Romit M.
  • 898
  • 11
  • 28
0

Many ways to achieve

  • Add a button above the label with same frame and do it on action
  • using Gesture Recognizers adding touch event to Label
Lithu T.V
  • 19,955
  • 12
  • 56
  • 101
0

Yes you need to drop a custom UIButton with clear background on your label with same frame size then connect button with action to open date picker

Pandey_Laxman
  • 3,889
  • 2
  • 21
  • 39
0

In the identity inspector, try to change the default class to UIControl class, that would allow you to add IBActions to your label. But a better way will be to use a textField instead of a label and put a background image and set its border to none from the attributes inspector. i hope it helps, Cheers!!

Apple_iOS0304
  • 1,092
  • 1
  • 9
  • 19
0

Here is something from stackoverflow itself.

StackOverflow

  1. No need to implement the responder.
  2. Remember to allow user interactions on the label.
  3. add tap gesture recognizer to that label.
  4. On click of that the action method will be called.
  5. Setup an actionsheet/view with the code mentioned in the above URL.
Community
  • 1
  • 1
S.P.
  • 3,054
  • 1
  • 19
  • 17