How to display date like on iOS 7 UIDatePicker calendar

I am new to iOS development, learning bits and pieces. I have a few more requests to continue to another thread ( iOS7: how Apple makes the navigation controller look like a uiaewsheet in a calendar application ) to create a new iOS 7 event in the default calendar, which is displayed when we click + on the UINavigationBar (suppose).

Does anyone know how to create a UIDatePicker so that it appears / hides when I click on the "Start / End Date" field? I saw one video where the UIActionSheet was used in Xcode 4.5, but for this user you need to click the "Finish, etc." button to hide it. It is hidden in the iOS 7 calendar when I click on an external device of choice, that is, in the "Start Date" field. Hope the question is clear?

Please advise how to achieve this feature?

+6
source share
2 answers

You can try using OCCalendarController , it is so simple and convenient. Just download the archived file and get all the files named after the OC prefix.

From which you can make the necessary changes to OCCalendarViewController.m by adding the Okay or Cancel buttons programmatically, on your own.

To invoke the calendar view in your main file, use the lines

//Here where the magic happens calVC = [[OCCalendarViewController alloc] initAtPoint:CGPointMake(150, 50) inView:self.view]; calVC.delegate = self; [self.view addSubview:calVC.view];

Also include the following delegate to get a date picker (if the user selects a date or date range)

- (void)completedWithStartDate:(NSDate *)startDate endDate:(NSDate *)endDate {

Finally, you can also customize the arrow (which appears along with the calendar view) using the code,

[OCCalendarViewController alloc] initAtPoint:insertPoint inView:self.view arrowPosition:OCArrowPositionRight]

Other details can be found in the read me file. Try yourself, it will work like a charm. Thanks!

+1
source

My open source project HSUDatePicker can help you. https://github.com/tuoxie007/HSUDatePicker

0
source

Source: https://habr.com/ru/post/955792/


All Articles