简体   繁体   中英

UIPickerView interactive area for tapping cut off in iOS 7

When I make a long picker with multiple components, only the components near the center react to the tap-to-select feature.

For example, if you want to pick the very next row under a selected row, you should be able to just tap it to make it animate up into the selection area. This feature still exists with iOS 7, but the area with in the UIPicker that will actually accept the tap is a very small window, no larger than 200px.

Is there any way to expand this tap-able area to include the entire UIPickerView, so any time you tap a row it becomes the selection?

EDIT here is the code, it's pretty standard...

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

    NSLog(@"picked %i %i" , component , row);
}


- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
    return 4;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
    return 15;
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
    return @"";
}

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
    UILabel *pickersLabel;

    pickersLabel =[[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, view.frame.size.width , view.frame.size.height )];
    pickersLabel.text = [NSString stringWithFormat:@"thing %i" , row ];


    pickersLabel.backgroundColor = [UIColor clearColor];

    pickersLabel.backgroundColor = [UIColor colorWithRed:1/255.0 green:1/255.0 blue:2/255.0 alpha:0.05];

    pickersLabel.opaque = NO;
    [view addSubview:pickersLabel];
    return pickersLabel;
}

我在.xibs中而不是在iOS 7中的Storyboard中遇到了UIPickerViews的大量问题。我不确定Storyboard的幕后是否进行了一些优化,或者这是否是一个直接的bug,但这是值得的镜头-我现在使用的是从情节提要中获取的选择器视图,我可以点击未选择的行,然后它们向上滚动并被选中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM