uidatepicker

Add AM/PM to datepicker?

假装没事ソ 提交于 2019-12-01 18:34:53
问题 My UIDatePicker is set to UIDatePickerModeTime but on the apple documentation it says The date picker displays hours, minutes, and (optionally) an AM/PM designation. The exact items shown and their order depend upon the locale set. An example of this mode is [ 6 | 53 | PM ]. . How do i add AM/PM because on my device, those aren't options and it instead uses a 24 hour clock? 回答1: This will depend on the settings of the user. If you go to Settings -> General -> Date & Time. there is a "24-Hour"

Add AM/PM to datepicker?

强颜欢笑 提交于 2019-12-01 18:03:41
My UIDatePicker is set to UIDatePickerModeTime but on the apple documentation it says The date picker displays hours, minutes, and (optionally) an AM/PM designation. The exact items shown and their order depend upon the locale set. An example of this mode is [ 6 | 53 | PM ]. . How do i add AM/PM because on my device, those aren't options and it instead uses a 24 hour clock? This will depend on the settings of the user. If you go to Settings -> General -> Date & Time. there is a "24-Hour" time switch, and based on that users will have the AM/PM indicator on your picker. Unfortunately

iOS - Dismiss UIDatePicker presented as inputView

感情迁移 提交于 2019-12-01 17:36:44
I have a text field in my UI that when it's selected presents a UIDatePicker instead of the default keyboard, how could I set up a button as to dismiss the picker when the user is done? What I do is have my inputView as a custom view which contains a UIDatePicker and a toolbar above it with a 'Done' button wired up to a method that calls a delegate method to tell the object that owns the UITextField to dismiss the "keyboard" by calling resignFirstResponder . Create a UIView (namely customDatePickerView) and in that view ,create datepicker and a done button and a cancel button in the xib. In

XCode: Why is my event not being added to the calendar?

非 Y 不嫁゛ 提交于 2019-12-01 17:16:53
问题 I have added the following code to my app: NSDate * selected = [DatePicker date]; NSString * date = [selected description]; NSDateComponents *components = [[NSCalendar currentCalendar] components:NSDayCalendarUnit fromDate:DatePicker.date]; CalLabel1.text = [NSString stringWithFormat:@"%d", [components day]]; EKEventStore *store = [[EKEventStore alloc] init]; EKEvent *event = [EKEvent eventWithEventStore:store]; event.title = @"Test Event"; //required event.startDate = [DatePicker date];

UIDatePicker setting minimum and maximum hour

醉酒当歌 提交于 2019-12-01 14:28:23
How to set minimum and maximum hour to UIDatePicker ? At all is it possible ? I know how to set minimum and maximum date: [datePicker setMinimumDate: today]; [datePicker setMaximumDate: nextMonthDay]; What i want to achieve is that in picker user could select from 8 am to 10 pm every day. Thanks. Hope the following code help you. - (IBAction)dataPickerValueChanged:(UIDatePicker *)sender { NSDateComponents *dateComponents = [[NSCalendar currentCalendar] components:NSHourCalendarUnit fromDate:[testDatePicker date]]; if ([dateComponents hour] > 8 && [dateComponents hour] < 22) { UIAlertView

DatePicker Stopping CoreData Work

大兔子大兔子 提交于 2019-12-01 14:03:54
I have an app which saves text and the date from a UIDatePicker and then shows that note if you got back into that date in the UIDatePicker. Its works great! Only I have found that setting the UIDatePicker date to today stops CoreData working! Its only when I run this setDate line does it stop core data from working. The app runs fine without crashing, it just doesn't save any data. If I comment that line out, its works a charm. But I need to have the UIDatePicker on today when the app loads. I use this when the application starts: NSDate *now = [[NSDate alloc] init]; [datePicker setDate:now];

Setting frame to Date picker in iOS7

a 夏天 提交于 2019-12-01 13:47:13
问题 I am able to set date picker frame from Storyboard. But I am not able to set the frame programatically. I would like to no why datePicker.frame is not working even though setFrame: functionality is not deprecated in iOS7. Also please provide a way to set date picker frame programatically. Any help is greatly appreciated. 回答1: If you have already added UIDatePicker to .nib or .storyboard file and would like to update frame programatically, then you can update frame inside viewDidLayoutSubviews

UIDatePicker setting minimum and maximum hour

折月煮酒 提交于 2019-12-01 13:07:19
问题 How to set minimum and maximum hour to UIDatePicker ? At all is it possible ? I know how to set minimum and maximum date: [datePicker setMinimumDate: today]; [datePicker setMaximumDate: nextMonthDay]; What i want to achieve is that in picker user could select from 8 am to 10 pm every day. Thanks. 回答1: Hope the following code help you. - (IBAction)dataPickerValueChanged:(UIDatePicker *)sender { NSDateComponents *dateComponents = [[NSCalendar currentCalendar] components:NSHourCalendarUnit

iOS - Change Language for UIDatePicker by locale

六眼飞鱼酱① 提交于 2019-12-01 11:49:30
I'm creating the app in "Herbrew" language. (Language of IPhone can be anything, but my app runs only in Herbrew). In iOS for UIDatePicker, we have a property "locale" which will change the language that it is displaying. But in iOS5, the property is deprecated. How can I achieve it now? Unfortunately, you cannot achieve this, not even with the calendar trick described by Martin Ulrich. I've struggled with the same problem myself and after a long research, I found out the bitter truth: the only way to change the localization of the UIDatePicker is to change the device's language. If the user

UItableViewCell with UIDatePicker : month column gets covered

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 11:33:13
UIDateTimePicker dropped on contentView of UITableViewCell in InterfaceBuilder Xcode 6.1 gets covered by white tiles. How to prevent it? Update: This issue is resolved as of iOS9 beta 5. (2015.08.24) There seems to be a bug in UIDatePicker on iOS8. We just noticed this in Portrait mode on an iPad: @BS4248 - Is this similar to what you're seeing? For us, the Hour column is missing instead of the Month column. It doesn't happen on any device running iOS7 and it doesn't happen on iPhones. I was curious what was happening here so I set the background color of the datepicker to red in the debugger