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

前端 未结 2 998
再見小時候
再見小時候 2020-12-16 12:51

I have been beating my head against the wall trying to diagnose my app\'s inability to automatically preselect the last row of a UIPickerView using code that successfully wo

相关标签:
2条回答
  • 2020-12-16 12:55

    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.

    0 讨论(0)
  • 2020-12-16 13:01

    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.

    0 讨论(0)
提交回复
热议问题