uidatepicker

Replacing UITextField input with a UIDatePicker

守給你的承諾、 提交于 2019-12-22 05:31:59
问题 I have a table view controller with (among others) a cell that is to represent a date. I followed this post "How do I make a modal date picker that only covers half the screen?" and I have it working with one big exception - I can't get the picker to disappear! I tried registering for the event UIControlEventTouchUpOutside, but it seems that this is not generated by the picker (or at least in the mode that I am using it). How can I recognize that the user has finished selecting a date? Also,

UIDatePicker NSRangeException crash iOS 11

吃可爱长大的小学妹 提交于 2019-12-21 12:14:46
问题 I have the following code to add a DatePicker to one of my UIViews. UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 30, 320, 250)]; [datePicker setDatePickerMode:UIDatePickerModeDate]; datePicker.hidden = NO; datePicker.date = [NSDate date]; [datePicker addTarget:self action:@selector(changeDateInLabel:) forControlEvents:UIControlEventValueChanged]; [self.dateView addSubview:datePicker]; This code has been around for a while but we've been noticing some random

UIDatePicker with 15m interval but always exact time as return value

元气小坏坏 提交于 2019-12-21 06:59:28
问题 I've got a UIDatePicker in Time mode with an interval of 15 minutes. Let's say it's 7:22PM. The value that the date picker shows per default is the current time rounded to the next higher/lower value, in this case, it's 7:15PM. If the user interacts with the date picker, the value that's shown is also the value returned. However if there hasn't been any user interaction and I get the time with [UIDatePicker date] the return value is the exact current time, i.e. 7:22 to stick with the example.

UIDatePicker with 15m interval but always exact time as return value

不羁的心 提交于 2019-12-21 06:59:04
问题 I've got a UIDatePicker in Time mode with an interval of 15 minutes. Let's say it's 7:22PM. The value that the date picker shows per default is the current time rounded to the next higher/lower value, in this case, it's 7:15PM. If the user interacts with the date picker, the value that's shown is also the value returned. However if there hasn't been any user interaction and I get the time with [UIDatePicker date] the return value is the exact current time, i.e. 7:22 to stick with the example.

Retrieve date and time from UIDatePicker iOS

耗尽温柔 提交于 2019-12-21 04:39:16
问题 I want to retrieve date and time in format e.g "Friday May 31, 2013 12:00 pm". How can I achieve that with NSDateFormatter? 回答1: NSDate *myDate = datePicker.date; NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@"cccc, MMM d, hh:mm aa"]; NSString *prettyVersion = [dateFormat stringFromDate:myDate]; 来源: https://stackoverflow.com/questions/16559541/retrieve-date-and-time-from-uidatepicker-ios

iOS9: UIDatePicker with datePickerMode of UIDatePickerModeTime only shows Hours, and no Minutes

旧巷老猫 提交于 2019-12-21 04:01:30
问题 I'm using Xcode beta 7 with the iOS9 simulator. Using a UIDatePicker with a datePickerMode of UIDatePickerModeTime only shows Hours, and not minutes. See screenshot: On iOS 7 and 8, obviously it works as expected, and shows both Hours and Minutes. Screenshot: I really do not want to reinvent the wheel and roll my own time picker. Any ideas on why this might be happening and how to fix? I can't find anything on google. thanks, Alex 回答1: Found a useful description of this problem in the iOS 9

Comparing an NSDate to [NSDate date]

霸气de小男生 提交于 2019-12-20 20:31:11
问题 I am trying to force a user to select a date in the future with a date picker. I obviously used the compare: method, however, when I do the following code, even if it's the same date as [NSDate date], it tells the executes the if statement. Here is my code: if ([datePicker.date compare:[NSDate date]] == NSOrderedAscending) // If the picked date is earlier than today { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hmm, this date is earlier than today" message:@"The date you've

Swift: One UITimePicker, Multiple Textfields

一个人想着一个人 提交于 2019-12-20 03:18:16
问题 I have a single UIDatePicker variable that has only the time. I want that to be able to set different times to different TextFields . The way I have it set up is that when I change one time, they all change. Code: *@IBOutlets for all the UITextFields...* private var datePicker = UIDatePicker() override func viewDidLoad() { super.viewDidLoad() self.setupDatePicker() self.setupTextFields() } func setupDatePicker() { self.datePicker.frame = CGRect(x: 0, y: 50, width: self.view.frame.width,

iOS - Dismiss UIDatePicker presented as inputView

∥☆過路亽.° 提交于 2019-12-19 18:56:17
问题 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? 回答1: 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 . 回答2: Create a UIView (namely

iPhone UIDatePicker in Landscape mode?

╄→尐↘猪︶ㄣ 提交于 2019-12-19 10:11:07
问题 iPhone UI Componenet UIDatePicker does not support Landscape mode? it scratches 2/3 of the width in Landscape mode only. How to make it use up full width (480px)? 回答1: Try to manually re/set the UIDatePickers' subviews bounds like this: - (void) viewDidLoad { [super viewDidLoad]; for (UIView * subview in datePicker.subviews) { subview.frame = datePicker.bounds; } } Everything is nicely described in this article: Using UIDatePicker in landscape mode 来源: https://stackoverflow.com/questions