UIPickerView 重新加载组件不工作
我正在制作一个使用选择器视图的应用程序。当应用程序加载时,选择器视图将获得初始选项。然后,我希望通过更改委托中使用的数组,然后在按下按钮触发的 IBAction 中调用 reloadcomponent 方法来更改这些选项。当我这样做时,什么也没有发生。最初的选择仍然存在。 Delegate 和 dateSource 均设置为文件所有者。任何帮助或建议表示赞赏。下面是 IBAction 中使用的代码(NSLog 显示数组已正确更改):
NSArray *myArray = [[NSArray alloc] initWithObjects:@"Elec Beat 1",@"Elec Beat 2",@"Elec Beat 3",@"Elec Beat 4",@"Elec Beat 5",nil];
[pickerChoices removeAllObjects];
[PickerChoices addObjectsFromArray:myArray];
[pickerView reloadComponent:0];
packSelect = 1;
NSLog(@"%@",pickerChoices);
Im making an app that uses a picker view. When the app loads, the picker view is given initial options. I then wish to change these options by changing the array used in the delegate and then calling the reloadcomponent method in an IBAction triggered by a button press. When i do this, nothing happens. The initial choices are still there. Delegate and dateSource are both set to files owner. Any help or suggestion is appreciated. Below is the code used in the IBAction (the NSLog shows that the array is getting changed correctly):
NSArray *myArray = [[NSArray alloc] initWithObjects:@"Elec Beat 1",@"Elec Beat 2",@"Elec Beat 3",@"Elec Beat 4",@"Elec Beat 5",nil];
[pickerChoices removeAllObjects];
[PickerChoices addObjectsFromArray:myArray];
[pickerView reloadComponent:0];
packSelect = 1;
NSLog(@"%@",pickerChoices);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你实现了 UIPickerViewDelegate 和 UIPickerDataSource 的方法吗?
Have you implemented methods of UIPickerViewDelegate and UIPickerDataSource?