uidatepicker

iPhone datepicker instead of keyboard?

依然范特西╮ 提交于 2019-11-27 00:10:45
问题 How would you do that? I have a form with a UITextField. When I click in it I would like to display a UIDatePicker instead of the default Keyboard that pops-up by default? Note that there are also other elements on my form. 回答1: I think this is a more official way to do this: UIDatePicker *datePicker = [[[UIDatePicker alloc] init] autorelease]; datePicker.datePickerMode = UIDatePickerModeDate; [datePicker addTarget:self action:@selector(datePickerValueChanged:) forControlEvents

Limiting UIDatePicker dates from a particular time. Such as Input DOB to a restricted age limit

元气小坏坏 提交于 2019-11-26 22:58:52
In my code, I have a UITextField that when the user taps on opens a UIDatePicker to enable the user to easily and efficiently scroll through to their Date Of Birth. Obviously, we wouldn't want the UIDatePicker to scroll up to 2015 and over as it currently does. As it's a Date Of Birth entry field, i would also need to be able to limit entries to 16years+. How do i do this? class SignUpViewController: UIViewController, UITextFieldDelegate { var datePicker:UIDatePicker! @IBOutlet weak var dateTextField: UITextField! override func viewDidLoad() { super.viewDidLoad() // UI DATE PICKER SETUP var

Display datepicker on tapping on textfield

不打扰是莪最后的温柔 提交于 2019-11-26 19:51:23
How can I display a datetimepicker control on tap of a textbox? I have a user interface that has arrival and departure text fields, and when a user clicks on arrival textbox it should bring up a datetimepicker control up instead of a keyboard and the same with the departure textbox. Deepak Danduprolu You can use inputView and inputAccessoryView properties of the text field for this. Create the date picker and set it to the input views of the two text fields. Also create another view for the Done button and it as their accessory view. You will need that button to dismiss the input view. The

Displaying the Day Of The Week From Date Picker

谁都会走 提交于 2019-11-26 17:22:35
问题 I want to store just the day of the week as a string using a datePicker in xcode using swift. 回答1: import UIKit class ViewController: UIViewController { @IBOutlet weak var myDatePicker: UIDatePicker! @IBOutlet weak var strWeekday: UILabel! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. // set mode to date only myDatePicker.datePickerMode = UIDatePickerMode.Date // add target for the trigger update function to change

UIDatePicker - Problem Localizing

旧时模样 提交于 2019-11-26 17:01:32
问题 I've created a UIDatePicker in my app and I also have support for several languages. My UIDatePicker is created in Interface Builder, and I have created a seperate localization XIB so I can customize my UIDatePicker. Setting the "Locale" option in IB appears to do nothing. Attempting to change my DatePicker programatically with Locale and NSCalender also do nothing via the following code: NSLocale * locale = [[NSLocale alloc] initWithLocaleIdentifier:@"es_ES"]; datePicker.locale = locale;

UIDatePicker select Month and Year

微笑、不失礼 提交于 2019-11-26 16:08:14
I need a UIDatePicker for selecting Month and Year only. I checked the class reference documents. Looks like UIDatePicker is a UIView . I imagined UIPickerView may be a sub view and I can hide the component if I can grab it. But no. That was not possible. Do I have to create my own custom picker then? Any ideas? Yeah, you probably want to just make your own picker. You don't have to subclass it or anything, though; just use a generic UIPickerView and return appropriate values from your UIPickerViewDelegate / UIPickerViewDataSource methods. Igor Here is a solution to get the same effect. For

UIDatePicker, setting maximum and minimum dates based on todays date

走远了吗. 提交于 2019-11-26 15:49:45
问题 If I have a UIDatePicker, and I wish to set the minimum and maximum date range to be between thirty years ago and thirty years in the future, how would I set that up? 回答1: Not tested, but you probably want something like this. NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDate *currentDate = [NSDate date]; NSDateComponents *comps = [[NSDateComponents alloc] init]; [comps setYear:30]; NSDate *maxDate = [calendar dateByAddingComponents:comps

Change UIDatePicker font color?

放肆的年华 提交于 2019-11-26 15:45:46
问题 All I want to do is change the font color of the UIDatePicker. I've researched other questions but they're all involving changing other properties and customizing the entire look. All I want to do is just change the font color from black to white. I find it hard to believe that I can't do such a seemingly simple task. And why wouldn't the tint color affect it? Does it even do anything? 回答1: All I need (on iOS 8.x and 9.0) is this one line to change the font color: [my_date_picker setValue:

UIDatePicker show only month and day

≯℡__Kan透↙ 提交于 2019-11-26 14:29:34
问题 I'd like to have a UIDatePicker where the user can pick a month and a day but not the year. I'm aware that leap years have an extra day, so for simplicity, let's throw that day away. Is there any way to remove the year column or have 2 reels with month/day that act like the UIDatePicker (grey out days that don't exist in the selected month)? 回答1: You cannot use the UIDatePicker class as it stands to do this - The UIDatePicker only supports the following modes typedef enum {

iOS 7 - How to display a date picker in place in a table view?

我的梦境 提交于 2019-11-26 12:36:32
In WWDC 2013 video, Apple suggests displaying picker in place in a table view in iOS 7. How to insert and animate a view between table view cells? Like this, from the Apple calendar app: Nitin Gohel With iOS7, Apple released the sample code DateCell . Demonstrates formatted display of date objects in table cells and use of UIDatePicker to edit those values. As a delegate to this table, the sample uses the method "didSelectRowAtIndexPath" to open the UIDatePicker control. For iOS 6.x and earlier, UIViewAnimation is used for sliding the UIDatePicker up on-screen and down off-screen. For iOS 7.x,