Reputation: 1
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..!
Upvotes: 0
Views: 1977
Reputation: 31
I don't see your .delegate method, but make sure you have it in this order:
mypicker.delegate = self;
[mypicker selectRow:[[General sharedInstance] displayMode] inComponent:0 animated:YES];
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:
[mypicker selectRow:[[General sharedInstance] displayMode] inComponent:0 animated:YES];
mypicker.delegate = self;
A hint: My class is UIViewController child.
Upvotes: 3