我的 Storyboard中有一个 UIPickerView。 包含它的 UIViewController 设置了接口(interface)声明
@interface ContactDetail : UIViewController <ABPeoplePickerNavigationControllerDelegate, UIPickerViewDataSource, UIPickerViewDelegate,UIAlertViewDelegate, UITextFieldDelegate>
on view Load, pickerview委托(delegate)集
pickerView_RelationshipType.dataSource=self;
pickerView_RelationshipType.delegate = self;
pickerView_RelationshipType.showsSelectionIndicator = YES;
除那两个之外,所有 UIPickerView 数据源和委托(delegate)方法都被触发
pickerView:titleForRow:rowforComponent
and
pickerView:viewForRow:forComponent:reusingView
调用下面的,没问题
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
- (void)pickerView:(UIPickerView *)pickerView didSelectRow: (NSInteger)row inComponent:(NSInteger)component
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
最佳答案
numberOfComponentsInPickerView
中有什么?
如果您的 numberOfRows
返回 0,那么您的委托(delegate)方法将永远不会被调用 - 如果选择器认为没有任何行要显示,则它不会询问行的标题。
关于ios - UIPickerView pickerView :titleForRow:rowforComponent method not called,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26713736/