UIPickerView can't autoselect last row when compiled under Xcode 4.5.2 & iOS 6

天涯浪子 提交于 2019-11-29 03:11:49

This bug is caused by the Use Autolayout option in the storyboard, but I have found a workaround that allows me to continue using auto layout:

If I call the [pickerView selectRow:inComponent:] method in the viewDidAppear: of my view controller instead of in the viewWillAppear:, then the UIPickerView correctly adjusts to select the correct row though the selection is momentarily visible as the picker rotates from the wrong selection to the correct one.

Definitely looks like a bug relating to the new auto-layout feature in iOS 6. I was experiencing the same thing, but when trying to see if it happened in iOS 5.1, I noticed that it started working.

Try this: in the storyboard or nib file in question, turn off auto-layout.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!