开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜