Chen Li Yong
Chen Li Yong

Reputation: 6107

Display UIDatePicker With ViewController (modalPresentationStyle = UIModalPresentationPopover)

I've just started to learn how to show UIDatePicker using PopoverController (still not working though), and Xcode already told me that it's deprecated.

It's still very rare to see tutorial made for the new ways, let alone with DatePicker inside of it. And some of the tutorial is written in Swift, while I learn objective C. I need a simple code example that can show DatePicker at the touch of TableViewCell, no matter where the cell position is in the screen (I also hoped that the popover view would not popped over outside or partially outside the screen), a button below the picker for accept the value, and auto dismiss the popover if user tap outside the popover. I've tried to implement this example, which does not using popover, but the result is weird. I also have read this as the knowledge base start for me to learn about the new way to do popover, but it doesn't show me how to put a DatePicker and a button inside of it. Can anybody help?

Oh, btw, I use UITableViewController, if that can means anything for the solution. Thanks.

Upvotes: 0

Views: 1482

Answers (2)

jeet Kumar
jeet Kumar

Reputation: 231

UIPopoverController deprecate in iOS 9.x version . Only just show warning you can replace UIPopoverController to UIPopoverPresentController and use that controller properties and delegates method Read from below link https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIPopoverController_class/index.html Read from below link https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIPopoverPresentationController_class/

Drag Datepickerviewcontroller in storyboard select Datepickerviewcontroller after that drag uidatepicker, button, create IBoutlate And Action . Datepickerviewcontroller Connect with segue of firstviecontroller button and select segue go to Attribute Inspactor section and select the animation style popover presenting type

Upvotes: 2

Umair Aamir
Umair Aamir

Reputation: 1644

You can use this library, it is very helpful for all kind of pickers. you can show picker with just one line ActionSheetPicker. It is developed in Objective C

Upvotes: 2

Related Questions