Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

slammers

macrumors newbie
Original poster
Sep 28, 2008
6
0
I created a simple view in Interface builder with a UItextfield and UIDatePicker.

I open the view and set the DatePicker date in the ViewDidLoad method. However, when the view loads the picker displays a strange date like November 28 0002.

I setup a method to respond to the date change event and this method is called three times while the view is loading. Each time the method is called I checked the date of the DatePicker and each time it has the correct date.

I am at total loss why this is happening. Does anyone have any idea what would cause this?

Thanks
Shawn
 

mozmac

macrumors 6502
Apr 28, 2005
332
15
Austin, TX
Did you ever figure out this problem? I am having it right now. I'll probably go back and recreate some things to see if I messed up somewhere along the line. But I would like to hear what you did to fix this.
 

slammers

macrumors newbie
Original poster
Sep 28, 2008
6
0
Unfortunately, no. I did not find a solution for this so I had to do it a different way. I hide the date picker when the view loads and then pop it up when the user clicks in a UITextField control. This way the picker does all its weird stuff while hidden. When the user clicks the text field I set the picker date and set its hidden property to false. It then gets shown with its correct date.

Shawn
 

mozmac

macrumors 6502
Apr 28, 2005
332
15
Austin, TX
I found the problem. Looks like it was a bug in version 2.0 of the SDK. When I loaded it to my iPod Touch running 2.1, everything worked fine. In your Xcode project, there is a drop down list on the top left where you select if you want to run your app in the simulator or on a device. Make sure everything in there is set to use 2.1, including the "Active Executable." As you switch between Simulator and Device, the Active Executable defaults back to 2.0, so you'll need to set it 2.1 again.
 

Brendan.Porter

Contributor
May 19, 2007
37
1
Twin Cities Metro
I created a UIDatePicker based app, and I discovered some strange things happening when I calculated the difference between two different NSDates. The bug exists in the SDK, specifically with placing a UIDatePicker in the app with InterfaceBuilder. I don't know why or how this happens, but to fix this you need to remove the UIDatePicker from Interface Builder and instead programmatically create, place, and initialize the UIDatePicker object (I made mine in -(void)awakeFromNib, but you don't have to).

Doing this fixed all of the weird bugs in my app. I hope this helps...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.