ios - 如何在 UIPicker 中首先选择具有特定标题的数组

标签 ios objective-c xcode multidimensional-array uipickerview

您好,我想在 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/

相关文章:

php - 只有一半的推送通知到达设备 (APNS)

ios - AVComposition 在 Airplay 上中断

objective-c - iPad相机方向纵向模式?

iphone - 寻找优秀的教程来帮助 ASP.NET 人员学习 iPhone 开发

xcode - 查看导致 pthread_mutex_lock 死锁的原因

ios - Gmail API 自动登录 swift

ios - Swift 2.2 AVPlayer 错误处理

iOS VoiceOver 按钮不调用目标方法

ios - UITableViewCell 重用单元格重复值

objective-c - NSBrowser setRowHeight,具有矩阵委托(delegate)的浏览器不支持