gpt4 book ai didi

ios - 4 NSarray 进入 pickerview

转载 作者:行者123 更新时间:2023-11-29 03:04:44 24 4
gpt4 key购买 nike

我怎样才能将 4 个 nsarrays 放入 1 个 pickerviewer每个数组中有 4 个名称。所以假设我有这个:

数组 1:亚历克斯

  • 电话号码:xxxxxxxxxx
  • 电话号码:xxxxxxxxxx
  • 电话号码:xxxxxxxxxx
  • 电话号码:xxxxxxxxxx

数组 2:安德鲁

  • 电话号码:xxxxxxxxxx
  • 电话号码:xxxxxxxxxx
  • 电话号码:xxxxxxxxxx
  • 电话号码:xxxxxxxxxx

数组 3:山姆

  • 电话号码:xxxxxxxxxx
  • 电话号码:xxxxxxxxxx
  • 电话号码:xxxxxxxxxx
  • 电话号码:xxxxxxxxxx

Array4:瑞克

  • 电话号码:xxxxxxxxxx
  • 电话号码:xxxxxxxxxx
  • 电话号码:xxxxxxxxxx
  • 电话号码:xxxxxxxxxx

现在,当我下拉 pickerviewer 时,我只想在该 pickerviewer 中看到名字 alex、andrew、sam 和 rick。

当我选择一个名字 (alex) 时,我想要将 4 个按钮更改为数字的值,这样当您点击按钮时,您可以调用它们。

谁能帮我解决这个问题。

此刻我的脑子有点冻僵了:S

最佳答案

将它们添加到字典中:

self.dict = [[NSMutableDictionary alloc] init]; //Obviously create a property first:

[dict setObject:array1 forKey:@"Alex"];
//etc .....

然后你的选择器代表看起来像:

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return [self.dict allKeys] count];
}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 1;
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [self.dict allKeys][row];
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {

NSString *person = [dict allKeys][row];
NSArray *personDetails = [dict objectForKey:person];
}

关于ios - 4 NSarray 进入 pickerview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22910981/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com