简体   繁体   中英

UIPickerView selectRow not working

I thought this would be simple, however....

All I want to do is select a row in a picker view on a button press. But this doesn't work.

int row;
row = [self.teamList indexOfObject:lastEvent.TeamWon];
[pickVRPossession selectRow:row inComponent:0 animated:NO];
[pickVRPossession reloadAllComponents]; //I tired this before and after selectRow but makes no difference

I know it's returning the correct index but it always remains on the first (or previously selected item) in the list. Any and all help appreciated.

The [pickVRPossession reloadAllComponents] would cause the UIPicker to reload data from the Delegate and lose your selection from the line of code before.

Lose the last line of your code snippet and you should be good to go.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM