开发者

HighLight Selection and Autoscroll up/down when using custom view in UIPickecrView

开发者 https://www.devze.com 2022-12-10 04:57 出处:网络
I have used Custom开发者_运维百科View.h and CustomView.m from UICatalog sample into my PickerView. But row is not selected/highlighted and scrolled up/down automatically. While the same is happened in

I have used Custom开发者_运维百科View.h and CustomView.m from UICatalog sample into my PickerView. But row is not selected/highlighted and scrolled up/down automatically. While the same is happened in standard picker view. How can I select/highlight and scroll up/down automatically with custom view in UIPicker? Thanks.


I answered a similar question here. Add the following code to your CustomView.m file:

- (void)didMoveToSuperview
{
 if ([[self superview] respondsToSelector:@selector(setShowSelection:)])
 {
  [[self superview] performSelector:@selector(setShowSelection:) withObject:NO];
 }
}

And also add self.userInteractionEnabled = NO to the (id)initWithFrame:(CGRect)frame function. This will allow you to keep the default autoscroll behavior of the UIPickerView.

0

精彩评论

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