如何获取UIPickerView中的项目数(行数)?我似乎找不到能告诉我这个的财产。
答案 0 :(得分:1)
@property(nonatomic,readonly)NSInteger numberOfComponents
答案 1 :(得分:1)
构建一个新的PickerViewHelper文件。为UIPickerViewDataSource委托实现此必需的方法。
@interface PickerViewHelper : UIViewController<UIPickerViewDelegate, UIPickerViewDataSource>
// returns the # of rows in each component..
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;
然后在UIViewController,获取数字:
long number = [self.yourPicker numberOfRowsInComponent : 0 ];