nit*_*hin 0 iphone objective-c uipickerview ios
我得到了一个字符串mild,medium,hot.我用逗号分隔字符串作为分隔符.我也需要在pickerView中打印它.
我使用以下代码并将List计数成功3.
NSString *spList=[mdict objectForKey:@"spicinesstype"];
NSArray *list = [spList componentsSeparatedByString:@","];
NSLog(@"List count:%d",[list count]);
return [list count];
Run Code Online (Sandbox Code Playgroud)
但是如何在pickerview中显示所有3个项目
您应该将您的类设置为选择器视图的委托,然后为您的选择器实现这3个委托方法
- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
return [array count];
}
- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [array objectAtIndex:row];
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
return 1;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2224 次 |
| 最近记录: |