0
我想在UIPickerView禁用第1行,但它拋出我下面的錯誤禁用行0 - iOS設備
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 2147483647 beyond bounds [0 .. 15]'
任何人都可以建議我出了什麼錯在這裏?這裏是代碼
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
AppDelegate *appdelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
if ((row > 0)){
NSLog(@"%@",[locationArray objectAtIndex:row]);
if(flag){
appdelegate.selectedLocation = [locationArray objectAtIndex:row];
NSLog(@"%@",appdelegate.selectedLocation);
} else{
appdelegate.selectedLocation = [locationArray objectAtIndex:row];
NSLog(@"%@",appdelegate.selectedLocation);
}
[promptLocation addSubview:tapButton];
[tapButton addTarget:self action:@selector(goToDesireLoc:) forControlEvents:UIControlEventTouchUpInside];
}else{
//Don't do anything if row 0 is chosen.
NSLog(@"do nothing");
}
}
顯然你沒有正確地得到所選行的索引 – Mil0R3