我有一个在 iOS 5.1 之前运行良好的应用程序。但最近在 iOS 6 中,当我尝试以编程方式选择组件中的一行时,它开始崩溃。以下是我的代码:
UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 40, 320, 216)];
pickerView.delegate=self;
pickerView.dataSource=self;
pickerView.showsSelectionIndicator=YES;
[pickerView setTag:10];
//[pickerView selectRow:0 inComponent:0 animated:YES];
int index1 = [arrHours indexOfObject:[arrTitle objectAtIndex:0]];
int index2 = [arrMins indexOfObject:[arrTitle objectAtIndex:1]];
[actionSheet addSubview:pickerView];
[pickerView selectRow:index1 inComponent:0 animated:YES];
[pickerView selectRow:index2 inComponent:1 animated:YES];
[pickerView release];
当我尝试在组件 0 中选择行时,它运行良好,但是当我尝试在组件 1 中选择行时出现崩溃。