Darshana
Darshana

Reputation: 314

Date picker iOS

I am really new to iOS development, and I know this will be a silly question but I need to do something like this: I have a button in my view, when I press it , then a date picker should appear. When a date is selected, date picker should disappear and the selected date should be shown in my UILabel.

How can I do this? I am using Xcode 5. I want to do this for iOS 7.

Please give me tutorial links, code samples, steps to follow or anything which I need to do this. Please help me.

Thank you!

Upvotes: 1

Views: 829

Answers (2)

Pham Hoan
Pham Hoan

Reputation: 2127

I just found this, maybe it will help :)

http://masteringios.com/blog/2013/10/31/ios-7-in-line-uidatepicker/

//edit: I skimmed through the tutorial, this is not a good example.

Use UIDatePicker is better.

Upvotes: 1

Add this code in your click event :

UIDatePicker *myPicker = [[UIDatePicker alloc] initWithFrame:pickerFrame];
[myPicker addTarget:self action:@selector(pickerChanged:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:myPicker];

Hope it will help you.

Upvotes: 0

Related Questions