UIDatePicker 15 Minutes Swift Increments

In swift , I wonder how I will use my UIDatePicker to select 15-minute increments. So instead of having a watch with 60 minutes, I only want to choose 00 minutes, 15 minutes, 30 minutes and 45 minutes.

Here is my current implementation

 var schedulePicker: UIDatePicker = UIDatePicker() schedulePicker.datePickerMode = UIDatePickerMode.DateAndTime schedulePicker.addTarget(self, action: "handleSchedulePicker:", forControlEvents: UIControlEvents.ValueChanged) textField9.inputView = schedulePicker .... func handleSchedulePicker(sender: UIDatePicker) { var dateFormatter = NSDateFormatter() dateFormatter.dateFormat = "MMM/dd/yy hh:mm a" textField9.text = "\(dateFormatter.stringFromDate(sender.date))" } 
+8
swift uidatepicker
source share
2 answers

Set shedulePicker.minuteInterval = 15

I found the answer here: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDatePicker_Class/#//apple_ref/occ/instp/UIDatePicker/minuteInterval

It is always useful to take a look at the documentation :)

+21
source share

You can set the attribute inspector in "Interval"

Interval

0
source share

All Articles