开发者

UIPickerView disable column

How ca开发者_JAVA百科n i disable UIPickerView column?

I want to disable only one column of picker. Lets say i have picker with 3 column and i want to disable second column.


There are a couple options here.

1) Capture interaction with the second column and override it.

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component;

This method can be implemented to simply go back to where it was before the selection. However, they will still be able to interact with the second column.

2) Simply remove the column from the picker.

I believe this is the best option. Have some boolean 'showSecondColumn'. Then, in:

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView

you can simply check your little flag and return the appropriate number. UIPickerView has a method: reloadAllComponents

Good luck!


It seems there is no way to disable column. I solved(not best solution) like this:

  1. get column as "image" (snapshot)
  2. grayscale "image"
  3. set "image view" user interaction enabled
  4. add "image view" to picker as subview

If there is any better way it would be great.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜