开发者

UIPickerView - changing component width

开发者 https://www.devze.com 2023-01-11 03:45 出处:网络
In my iPhone app I want to have a UIPickerView with 2 components. Initially the left column will be wide and the right column narrow to enable the text on the left to be read easily to allow selection

In my iPhone app I want to have a UIPickerView with 2 components. Initially the left column will be wide and the right column narrow to enable the text on the left to be read easily to allow selection from it.

Once this column has been selected the user will click on the right column to sel开发者_开发技巧ect an item from it : when this happens I want to resize the columns so that the left column is narrow and the right one is wide so that all the text can be read.

I have been experimenting with "pickerView widthForComponent" but this seems to only get called when the view is initially loaded.

Is there any way I can dynamically resize the columns ?

Thanks


You may use [pickerView reloadAllComponents].

Update:

That's weird. You may also try to check the following solution.


Just a reload won't work. You also need to call setNeedsLayout

[pickerView reloadAllComponents];
[pickerView setNeedsLayout];
0

精彩评论

暂无评论...
验证码 换一张
取 消