UIPickerVeiw multiple orientations return correct picker of loaded view
Ok here is my problem. I have a view that loads another view as subView when the device rotates. This is working perfectly. Now my problem is that I have a PickerView on each orientation's view that has outlets assigned to them, the why I implemented is as was suggested here: Two views Multiple UIPickerViews Single outlet The problem I am having is that when I populate my PickerViews the data is not being pulled through.
if(pickerView == pickerType) {
return [myHelper.types objectAtIndex:row];
}else if(pickerView == pickerTown){
return [myHelper.towns objectAtIndex:row];
}else
{
return @"";
}
As I understand that when I do this code:
- (UIPickerView *) pickerTown
{
if(self.landscapeView.superview)
{
return self.landscapeP开发者_如何学JAVAickerTown;
}else
{
return self.portraitPickerTown;
}
}
I will be able to access the picker on the correct view. But for some reason it is not working, I might be doing some thing wrong. Please help.
It might not be the best approach but when adding data do the following
if(pickerView == landscapePickerType || pickerView == portraitPickerType) {
return [myHelper.types count];
}else if(pickerView == landscapePickerTown || pickerView == portraitPickerTown){
return [myHelper.towns count];
}else
{
return 0;
}
Regards
精彩评论