I have a UIDatepicker created in UIBuilder and instantiated once when the app first loads. When first presented, the datepicker correctly flags today's date with the word 'Today'. On IOS 4, if I dismiss the app to the background, and reactivate it a day later, the date has advanced, but yesterdays date is still flagged as 'Today'. Explicitly updating the controls date has no effect. It looks like the control determines 'Today' only once, when created.
I've tried calling init to re-initialise it in-situ, but can't get that to work.
Am I missing something?
As a workaround for this bug you might catch the UIApplicationWillEnterForegroundNotification and dump and recreate the table cells to get a correct 'today' flag.
You can use UIDatePicker from Interface Builder. But when you return to the app you need to execute
[datePicker sizeToFit];
and it will updates "Today" cell.
The UIDatePicker shows the default value from your Interface Builder setting. I added UIDatePicker in viewDidLoad{} but not in Interface Builder, it works well.
Related
I need to create Custom UIDatePicker Control Displaying Only Days of week,Hours,Minutes and time Format(Am,Pm). I had just started iOS development so not having so much of idea.Any insights or reference appreciated. Thanks
Look at the datePickerMode property of UIDatePicker
The different available modes are :
typedef enum {
UIDatePickerModeTime,
UIDatePickerModeDate,
UIDatePickerModeDateAndTime,
UIDatePickerModeCountDownTimer
} UIDatePickerMode;
If you need days of week, you will need to implement a basic UIPickerView and add your own data on it.
You need to create your own customized pickers using UIPickerView. If we want to to use UIDatepicker,
Need to use date picker mode as UIDatePickerModeDateAndTime and we need to over shadow the other data which is not necessary.
hi
I am working on an iPhone app & i have to show some thing on a pickerview after receiving a response from socket, Methods of PickerView are check when application is going to be load. in my app i have to load PickerView on a button click.
After getting response in an array, When i click on button its shows a pickerview but empty. :(
SO can any body tell me how to reload the pickerview like tableView.
Thanx in advance
you could use either reloadAllComponents to realod all the component or reloadComponent to a zero-indexed number identifying a component of the picker view.
[myPickerView reloadAllComponents];
[myPickerView reloadComponent:IndexOfReloadComponent];
Read UIPickerView documentation
You can use below code, I hope it's work
[obj_Picker reloadAllComponents];
Call -reloadComponent: or -reloadAllComponents (methods on UIPickerView).
Quote:
You can dynamically change the rows of a component by calling the reloadComponent: method, or dynamically change the rows of all components by calling the reloadAllComponents method. When you call either of these methods, the picker view asks the delegate for new component and row data, and asks the data source for new component and row counts. Reload a picker view when a selected value in one component should change the set of values in another component. For example, changing a row value from February to March in one component should change a related component representing the days of the month.
Use this method - (void)reloadAllComponents of the UIPickerView class.
I want to remove year from iOS date picker. Need to use in iPhone app.
This is down to the users phone localization settings... You'll need to create some sort of custom UIPicker if you want to make it the same for all.
Quick and easy way, create your UIPickerView with just two components.
You can't use the UIDatePicker because The UIDatePicker only supports the following modes
typedef enum {
UIDatePickerModeTime,
UIDatePickerModeDate,
UIDatePickerModeDateAndTime,
UIDatePickerModeCountDownTimer
} UIDatePickerMode;
Create a view and controller that implement the UIPickerViewDelegate and create your own - you may find a little more detail here
Fixed labels in the selection bar of a UIPickerView
I just added a UIDatePicker to my iPad app using IB, linked it to its outlet in the code, saved it in IB, added the UIPickerViewDelegate to my UIViewController in the code, as well as added the UIDatePicker outlet in code. When I build and run, the app launches, but will crash intermittently when I attempt to open the popover view that contains the datepicker. I say intermittently because the popover view will occasionally open successfully, but never more than once (it always crashes the second time you open the popover, if it doesn't crash the first time). Also, in the console, I get the following messsage
objc[594]: FREED(id): message lastClickRow sent to freed object=0x6015a70
Why is this happening and how can I fix it?
What does that console message indicate?
It may be worth mentioning that the popover view also contains a table view along with the datepicker control.
Thanks so much in advance for your help!
I too had a tough time getting through this problem but at last got it resolved.
Instead of adding UIDatePicker in interface builder, add it dynamically or programatically. It surely worked for me and hope that it works for you too.
UIDatePicker *_datePicker=[[UIDatePicker alloc] initWithFrame:frame];
[self.view addSubview:_datePicker];
This is almost certainly a reference count issue. It seems odd that your view controller (which I'm assuming is the delegate of your UIDatePicker, since that's where you implemented the protocol) would be released during normal operations, but that's the first thing you should look at - that the delegate is set and remains a valid object at the time you display the popup view.
One funny thing you could have done is to release it UIPopOverController reference after passing it the [presentPopover...] message, just like we do at passing a presentModalViewController message to the UIViewController.
I faced this problem too, one thing you can do is something like
self.funnyPopoverController = aPopoverController;
(of course funnyPopoverController is retain type property here).
Otherwise its hard to predict whats happening without staring at the code for some long long time_t hours :)
is there a way to set the UIDatepicker to minute and seconds versus Hour and Minute
edit I ended up adding my own UIPicker class, and creating the value and label myself.
I don't think there is any builtin way to do this in the SDK. Try just subclassing UIPickerView and you should end up with basically the same result.
If you search the help for UICatalog it has full examples of pickers and how to make you own custom picker.
There is no option to show minutes seconds according to the API documentation.