views:

317

answers:

3

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
  1. Why is this happening and how can I fix it?
  2. 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!

A: 

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.

warrenm
A: 

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 :)

sid
A: 

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];

Mustafa Saify