您好,我想在 UIPicker 中显示一个列表,该列表保存在数组中。
它有效,但我想选择一个特定的标题作为标准。它应该是自动选择的。
示例:
Array
index______title
0_________Water
1_________Fire <--- the title with the name Fire should be automatically selected as standart.
2_________Storm
我的列表是灵活的,我不能每次都选择索引 1。 对于这个问题你有什么想法吗?
提前致谢
最佳答案
要实现此目的,您需要使用 selectRow:inComponent:animated:
self.pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 155, 0, 0)];
self.pickerView.delegate = self;
self.pickerView.showsSelectionIndicator = YES;
[self.pickerView selectRow:[YouArray indexOfObject:@"YourTitle"] inComponent:0 animated:NO];
[self.view addSubview:self.pickerView];
关于ios - 如何在 UIPicker 中首先选择具有特定标题的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15617654/