I have a perplexing problem in trying to sort out different behavior of the same code on an iPhone 4S running iOS 5.0 and an iPad running iOS 4.3.
The view controller code is associated with a view with a date picker to enter a date of birth. Via Interface Builder the date picker is associated with the received action “Value Changed” directed toward the view controller method -(IBAction)birthDate: (id)sender:
-(IBAction)birthDate: (id)sender {
//Code here executed when date of birth entered. Should not be executed when view loads.
}
It is very important in the app that this code NOT be executed when the view loads. I have demonstrated with a breakpoint insertion that this code does not execute when the view loads with iOS 5.0, but does execute when the view loads with iOS 4.3, causing a real problem with the program (the default birthdate becomes interpreted as an entered birthdate). I very much would appreciate advice on how to prevent the IBAction code from executing in iOS 4.3 unless the user changes the default date of birth. I also am very curious as to why this difference in behavior should exist. Thanks in advance.
This is a documented change to UIPickerView’s behaviour in iOS 5.0 (Release Notes)
One way to get around it on iOS 4.3 would be to have a BOOL that is set to YES at the beginning of
loadViewand NO at the end.Your value changed method
birthDate:could then check that this BOOL value is NO before handling the change.