UIPickerViewDelegate Protocol Bug

Originator:whitegregory33
Number:rdar://15338001 Date Originated:11/28/2013
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 7.0.3
Classification:Other Bug Reproducible:Always
 
Summary:
When implementing the method -pickerView:rowHeightForComponent in a UIPickerViewDelegate, the method is called more times than there are components in the PickerView.

Steps to Reproduce:
1. Use Xcode Version 5.0.1 (5A2053) on Mac OS X 10.9, build 13A603
2. Create empty application.
3. Add new UIViewController subclass with .xib, add PickerView to .xib.

4. In the AppDelegate:
4a. Create UIViewController subclass
4b. Create UINavigationController, initWithRootViewController using above subclass.
4c. Set window.rootViewController to the UINavigationController.

5. In the UIViewController subclass:
5a. Implement the UIPickerViewDataSource Protocol methods -numberOfComponentsInPickerView: & -pickerView:numberOfRowsInComponent:.  Return 1 for numberOfComponents.
5b. Implement the UIPickerViewDelegate Protocol methods -pickerView:titleForRow:forComponent:, -pickerView:rowHeightForComponent: & -pickerView:widthForComponent:.
5c. In the methods in 5a & 5b that require component number as input, add NSParameterAssert(component == 0).

6. Run the app in Xcode.

Expected Results:
I expected that the app would launch normally and I would be able to manipulate the picker view.

Actual Results:
The app launches, but then generates an assertion failure in pickerView:rowHeightForComponent: when this method is called with a component of 1.  This should not happen as the picker view is defined to only have one component by the data source implementation.

Version:
iOS 7.0

Notes:
This problem always occurs, however:
1.  Remove the NSParameterAssert from pickerView:rowHeightForComponent, and the app seems to launch normally.  Supplying a row height for a non-existant component seems to be a no-op.
2.  Remove pickerView:rowHeightForComponent from the delegate implementation, and the app seems to launch normally.  Did not track component number in this case.

Also, attached is a sample project/app to illustrate the problem.

Configuration:
Always occurs when the UIPickerViewDataDelegate method -pickerView:rowHeightForComponent is implemented.

Attachments:
'Sample App.zip' was successfully uploaded.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!