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
.
精彩评论