我是编码初学者,想只显示整数(1,2,3,4)
在我的UIPickerView
而不是(0.0,0.1,0.3,0,4)。
-(NSString *)pickerView:(UIPickerView *)pickerView
titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [NSString stringWithFormat:@"%ld, %ld",(long)component,(long)row];
}
谢谢
答案 0 :(得分:0)
您将要使用此方法:
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
Apple为这样的问题提供了很好的文档: https://developer.apple.com/library/IOs/documentation/UIKit/Reference/UIPickerView_Class/index.html https://developer.apple.com/library/IOS/documentation/UIKit/Reference/UIPickerViewDelegate_Protocol/index.html。
答案 1 :(得分:0)
您只需要将格式化的行返回给字符串。像这样:
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [NSString stringWithFormat:@"%ld", row];
}