uidatepicker

How to disable AM/PM in UIDatePicker

好久不见. 提交于 2019-11-29 01:19:20
How to disable or hide AM/PM in UIDatePicker from code / interface builder? I want to have 24 hours time picker mode in UIDatePicker . Please help According to the documentation you should be able to set the locale property of UIDatePicker to a locale that uses a 24 hrs format. NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"da_DK"]; [datePicker setLocale:locale]; [locale release]; Alas there is a bug causing both simulator and device to continue to layout the date picker according to the users international preferences. As you suggest, you have to roll your won date picker to

iOS开发10:UIDatePicker控件

佐手、 提交于 2019-11-28 23:33:03
UIDatePicker是一个可以用来选择或者设置日期的控件,不过它是像转轮一样的控件,而且是苹果专门为日历做好的控件,如下图所示: 除了UIDatePicker控件,还有一种更通用的转轮形的控件:UIPickerView,只不过UIDatePicker控件显示的就是日历,而UIPickerView控件中显示的内容需要我们自己用代码设置。本篇文章简单介绍UIDatePicker控件,后边的文章会介绍UIPickerView。 1、运行Xcode 4.2,新建一个Single View Application,名称为UIDatePicker Test,其他设置如下图所示: 2、单击ViewController.xib,打开Interface Builder。拖一个UIDatePicker控件到视图上: 3、然后拖一个按钮在视图上,并修改按钮名称为Select: 单击按钮后,弹出一个Alert,用于显示用户所作选择。 4、创建映射:打开Assistant Editor,选中UIDatePicker控件,按住Control,拖到ViewController.h中: 新建一个Outlet,名称为datePicker: 然后以同样的方式为按钮建立一个Action映射,名称为buttonPressed,事件类型为默认的Touch Up Inside。 5、选中UIDatePicker控件

Objective C: UIDatePicker UIControlEventValueChanged only fired on second selection

我们两清 提交于 2019-11-28 22:55:19
Working with UIDatePickers for the first time. To start, I'm just trying to update a text field with whatever value is selected from the datePicker (set in count down mode). It works, but only the second time that a user selects a time. My action, durationSelected() is only called the second time, so there are no problems updating the textField. Here's how I configured the date picker in my storyboard: Here's the action triggered on Value Changed: from DetailViewController.m - (IBAction)durationSelected:(UIDatePicker *)sender { self.durationTextField.text = [NSString stringWithFormat:@"%f

How do I rewrite the UIDatePicker component?

我只是一个虾纸丫 提交于 2019-11-28 19:35:18
I've noticed that the UIDatePicker doesn't work with NSHebrewCalendar in iOS 5.0 or 5.1. I've decided to try and write my own. I'm confused as to how to populate the data and how to maintain the labels for the dates in a sane and memory efficient manner. How many rows are there actually in each component? When do the rows get "reloaded" with new labels? I'm going to give this a shot, and I'll post as I find out, but please post if you know anything. First off, thanks for filing the bug about UIDatePicker and the Hebrew calendar. :) EDIT Now that iOS 6 has been released, you'll find that

UIDatePicker in UIActionSheet on iPad

人盡茶涼 提交于 2019-11-28 18:53:05
In the iPhone version of my app, I have a UIDatePicker in a UIActionSheet . It appears correctly. I am now setting up the iPad version of the app, and the same UIActionSheet when viewed on the iPad appears as a blank blank box. Here is the code I am using: UIDatePicker *datePickerView = [[UIDatePicker alloc] init]; datePickerView.datePickerMode = UIDatePickerModeDate; self.dateActionSheet = [[UIActionSheet alloc] initWithTitle:@"Choose a Follow-up Date" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"Done", nil]; [self.dateActionSheet showInView:self.view];

Show datepicker on textfield tap

*爱你&永不变心* 提交于 2019-11-28 17:55:42
I'm very new to iOS so obviously I'm missing a few concepts when trying to follow this solution Display datepicker on tapping on textfield to my problem. I have the interface and implementation in a class called DatepickerAppDelegate, but I'm lost here: "In the XIB, Pull out a UIToolbar and a UIDatePicker but don't attach it to the view. Connect the outlets appropriately. dateChanged: responds to changes in the date picker and doneEditing: is called when the Done button in the tool bar is clicked. Connect them too. The methods are implemented as listed below." I read something about XIB's but

Customize text color of UIDatePicker for iOS7 (just like Mailbox does)

会有一股神秘感。 提交于 2019-11-28 16:22:22
I'm having the most frustrating dilemma. I've researched up and down and can clearly see that Apple does not want us tampering with iOS 7. Well, I want to tamper. And, the team at Mailbox clearly figured out how to do it and get approved. The main thing that I'm trying to achieve is to change the label color to white. My first thought was they are using a custom UIPickerView that just mimics a UIDatePicker, but I just don't think this is the case. I zoomed in on a small fragment and discovered remnants of a normal UIDatePicker (black lines) along with clipping on the letter "W". Now I've

Elegantly replace iPhone keyboard with UIPickerView

大兔子大兔子 提交于 2019-11-28 16:07:33
I have a table view that has embedded UITextFields for entering some data. It also has two other fields that popup a UIPickerView and a UIDatePicker - as demonstrated in the DateCell example from Apple. Mostly it works but I can't figure out how to cleanly transition from the text field keyboard to the other pickers - one slides out, one slides in - it looks weird and the scroll position on the table view sometimes gets screwed up - with everything scrolled off the top. What I'd like to do is replace the text field keyboard without it animating away and without it growing the table view back

Is it possible to set UIDatePicker to only days (exclude hours, minutes and seconds)?

允我心安 提交于 2019-11-28 14:52:25
I'm trying to have a UIDatePicker to present only the date, month and year to the user. I want to avoid presenting them with the hours, minutes and seconds like it comes by default. I've tried looking for something that might help but can only find solutions that aren't explained clearly in Objective-C, however I'm coding in Swift. Any ideas? Thanks in advance! you need to chose the mode of the date picker @IBOutlet weak var myDatePicker: UIDatePicker! override func viewDidLoad() { super.viewDidLoad() myDatePicker.datePickerMode = .date // or .Date (Swift 2.x) } date picker options .

Converting String to NSDate Giving Wrong Date

你。 提交于 2019-11-28 14:40:30
I have a String that I converted using stringFromDate and now I'm trying to convert it back, however when the UIPicker starts, it's giving me the wrong day let dateFormatter = NSDateFormatter() dateFormatter.dateFormat = "dd MMM YYYY" print(birthday) // logs 15 Jan 1992 let date = dateFormatter.dateFromString(birthday) self.datePicker.setDate(date!, animated: true) I tried hardcoding "15 Feb 1992" but still the same result. The date on UIDatePicker shows 22 Dec 1991 on Start. If I use hardcore 10 Jan 1980 , it starts from 23 December 1979. (I don't know if that's the case but I have MMM dd