UIPickerView Selectrow inComponent 没有响应
我有标签栏控制器的视图部分。我已将 UIpickerview 添加到视图中。 uipickerview 的委托和数据源是视图控制器。
我有一个这样的编码,
- (void)viewDidLoad{
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg.png"]];
self.arrCurrencies = [[NSMutableArray alloc] init];
[self.arrCurrencies addObject:@"USD"];
[self.arrCurrencies addObject:@"GBP"];
[self.arrCurrencies addObject:@"INR"];
[self.arrCurrencies addObject:@"EUR"];
[self.arrCurrencies addObject:@"YEN"];
[self.arrCurrencies addObject:@"AUD"];
[self.arrCurrencies addObject:@"SGD"];
[self.pickerView reloadAllComponents];
[self.pickerView selectRow:2 inComponent:0 animated:NO];
}
我尝试了上面的代码,默认情况下它没有在pickerview中选择第三行或INR。有人可以建议我哪里错了..!
I've a view part of tab bar controller. I've added a UIpickerview to the View. The delegate and data source of the uipickerview is the viewcontroller.
I've a coded like this
- (void)viewDidLoad{
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg.png"]];
self.arrCurrencies = [[NSMutableArray alloc] init];
[self.arrCurrencies addObject:@"USD"];
[self.arrCurrencies addObject:@"GBP"];
[self.arrCurrencies addObject:@"INR"];
[self.arrCurrencies addObject:@"EUR"];
[self.arrCurrencies addObject:@"YEN"];
[self.arrCurrencies addObject:@"AUD"];
[self.arrCurrencies addObject:@"SGD"];
[self.pickerView reloadAllComponents];
[self.pickerView selectRow:2 inComponent:0 animated:NO];
}
I tried the above code, it's not selecting the 3rd row or INR in the pickerview by default. Can someone suggest me where I'm wrong..!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有看到您的 .delegate 方法,但请确保您按此顺序拥有它:
我在“selectRow”方法之后有委托调用方法,并且我疯狂地在互联网上寻找解决方案。两天时间,想了很多办法,只有这个!!!
所以,这不起作用:
提示:我的类是 UIViewController 子类。
I don't see your .delegate method, but make sure you have it in this order:
I had the delegate call method after the 'selectRow' method and I was mad looking for the solution in internet. 2 days with a lot of solutions, and only was this!!!
So, this doesn't work:
A hint: My class is UIViewController child.