user1541029
user1541029

Reputation:

Open date picker when user clicks textbox?

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?

Upvotes: 0

Views: 982

Answers (5)

Romit M.
Romit M.

Reputation: 898

use should use UITapGestureRecognizer to create tap event in UILabel

Upvotes: 1

S.P.
S.P.

Reputation: 3054

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.

Upvotes: 0

Apple_iOS0304
Apple_iOS0304

Reputation: 1102

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!!

Upvotes: 0

Pandey_Laxman
Pandey_Laxman

Reputation: 3908

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

Upvotes: 0

Lithu T.V
Lithu T.V

Reputation: 20021

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

Upvotes: 0

Related Questions