我的应用程序中有一个UIPickerView,它有四个看起来像这样的组件
Hour string | Hour title string | minutes string | Minutes title string
在小时字符串中我有一个字符串数组
0,1,2,3,4,5,6,7,8,9,10,11,12
小时标题字符串=小时
Minutes string是一个字符串数组
0,15,30,45
和分钟标题字符串=分钟
我想知道如何同时捕获组件0和3的值。
这就是我用myselectrow方法做的事情。
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
// Handle the selection
NSString *hours;
NSString *minutes;
hours = [hoursArrayPicker objectAtIndex:0];
minutes = [minutesArrayPicker objectAtIndex:1];
hoursCellString = [NSString stringWithFormat:@"%@ hrs and %@ min",hours, minutes];
[sheetsTableView reloadData];
}
但我没有捕捉到正确的信息。
答案 0 :(得分:0)
我已经弄清楚了。
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
// Handle the selection
NSString *hours;
NSString *minutes;
hours = [hoursArrayPicker objectAtIndex:[pickerView selectedRowInComponent:0]];
minutes = [minutesArrayPicker objectAtIndex:[pickerView selectedRowInComponent:2]];
hoursCellString = [NSString stringWithFormat:@"%@ hrs and %@ min",hours, minutes];
[sheetsTableView reloadData];
}