uidatepicker

How to set a maximum date for date picker swift 4?

ε祈祈猫儿з 提交于 2019-12-10 23:48:31
问题 I'm trying to set the maximum date to be 7 days ahead of the current date ( today's date). datePicker.maximumDate = 回答1: I've figured it out. var sevenDaysfromNow: Date { return (Calendar.current as NSCalendar).date(byAdding: .day, value: 7, to: Date(), options: [])! } datePicker.maximumDate = sevenDaysfromNow 回答2: I think this is easier: datePicker.maximumDate = date.addingTimeInterval(604800) 604800 seconds are 7 days. 来源: https://stackoverflow.com/questions/47004269/how-to-set-a-maximum

Create picker for date and time together in iPhone

删除回忆录丶 提交于 2019-12-10 22:06:23
问题 I am creating two pickers for date and time using UIDatePickerModeDate and UIDatePickerModeTime , but I want to create one picker for date and time together. I am new to iOS development. For date selection I use this code: datePick = [[UIDatePicker alloc]initWithFrame:CGRectMake(50, 290, 120, 0)]; datePick.datePickerMode =UIDatePickerModeDate For time selection I use this: timePick = [[UIDatePicker alloc]initWithFrame:CGRectMake(50, 200, 120, 0)]; timePick.datePickerMode =UIDatePickerModeTime

How to add UIDatePicker in UIAlertController in iOS8?

风流意气都作罢 提交于 2019-12-10 16:47:39
问题 I am working on a project which I had already released with iOS-7. But now as the action sheet is making problem so I am now implementing UIAlertController. Following is the code which I am using for showing UIAlertController with UIPicker. alertController = [UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:UIAlertControllerStyleActionSheet]; UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"" style:UIAlertActionStyleDefault handler:nil]; [alertController

How to hide future or past dates in UIDatePickerView

别来无恙 提交于 2019-12-10 15:56:28
问题 I want to design a UI for setting date of birth. For that I am choosing UIDatePickerView . Now I want to restrict the dates to between 01-01-1990 and current date. It should not show future dates and past dates. Currently I am using the following code: NSDateComponents *components=[[NSDateComponents alloc] init]; [components setYear:1900]; pickerView.datePicker.minimumDate = [[NSCalendar currentCalendar] dateFromComponents:components]; pickerView.datePicker.maximumDate=[NSDate date] It is

Insert blank value in date picker in Iphone

这一生的挚爱 提交于 2019-12-10 15:56:07
问题 I have a date picker which is shown using an action sheet. I want to insert a blank value in date picker and set it as default value. It should change only on user selection. Is this possible? If yes how? All valuable suggestions are appreciated. 回答1: UIDatePicker only supports certain modes and doesn't allow this kind of customization (adding in blank or custom data into the spinning pickers). Oh, the documentation indicates it doesn't inherit from UIPickerView either so you can't easily get

UIDatePicker not displaying properly in iOS 9

橙三吉。 提交于 2019-12-10 15:24:05
问题 I am NOT using auto layouts and this is how the UIDatePicker is appearing in my app on iOS 9. The picker is looking flawless in iOS 8 but the problem is only with iOS 9. Any idea how to resolve this.. (P.S using auto layouts in not a solution at the moment for me.) 回答1: In the viewDidLoad() method, change a property of the date picker, for example the mode. Note that, You don't have to leave it changed, you can set it to anything and then change it back to what you actually want. I am sure,

UIDatePicker show only Sunday's date only?

a 夏天 提交于 2019-12-10 14:36:37
问题 How we can set UIDatePicker values to show only Sunday's date in swift iOS ? 回答1: finally, I myself found solution. In didSelectRow Method check if the selected day is sunday??? if yes then ok but if not then reload component to select date of nearest sunday. func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { if component == 0 { pickerView.reloadComponent(1) } let titleLabel = pickerView.viewForRow(row, forComponent: component) as? UILabel

How can I set the UIDatePickerModeCountDownTimer's maximum time?

不打扰是莪最后的温柔 提交于 2019-12-10 13:45:31
问题 I want to ask that how can I set the iOS Count Down Timer's maximum time? (eg. 1 hour and 30 minutes at most) Count Down Timer is get from UIDatePicker 's mode: Thanks! EDIT: Someone said I have to set the minimum/maximum date, and I just set them in the storyboard but I don't see any difference: (the time of the setting is my local time +- 30 minutes) EDIT: From Apple: The minimum and maximum dates are also ignored in the countdown-timer mode (UIDatePickerModeCountDownTimer). So is their

UIDatePicker for a Non-Gregorian calendar

僤鯓⒐⒋嵵緔 提交于 2019-12-10 11:42:53
问题 I am using UIDatePicker in my App, which works fine for a Gregorian calendar. But I want to use a Non-Gregorian calendar with the DatePicker, which I didn't succeed to do it! I need it to do some conversion from Non-Gregorian to Gregorian dates, so it must work the same whatever the iPhone 'Locales' are. Please can you answer this! Your help is really appreciated, 回答1: Did you try setting the UIDatePicker 's calendar property to a non-Gregorian calendar? 来源: https://stackoverflow.com

Converting NSDate from a calendar to another

回眸只為那壹抹淺笑 提交于 2019-12-10 10:35:22
问题 I'm having trouble here. Took me hours but no use. Please keep in mind I checked the heck of StackOverFlow for a fix but there isn't any. When I convert the _date Object from Gregorian to Hijri it does not convert. I know that because when I print it it still gives me the Gregorian day. This troubles me because I want to setDate of a UIDatePicker and it's setting it incorrectly because the _date is gregorian and my UIDatePicker object calendar set to setCalendar:_hijriCalendar //DATE SETTING