在UIPickerView中进行选择时,如何删除蓝色突出显示

问题描述

| 当我在修改的选择器视图中选择一个单元格时,将显示蓝色背景色。 我见过的所有其他胎面都无法给我一个很好的答案。 有人有解决方案吗?     

解决方法

pickerView.showsSelectionIndicator = NO;     ,只需将UITableViewCell selectionStyle属性设置为UITableViewCellEditingStyleNone
cell.selectionStyle = UITableViewCellEditingStyleNone;
    ,我在选择器视图的顶部添加了工具栏,并在按钮的子视图中添加了按钮按钮,选择器视图和工具栏都被添加为主视图的子视图,因此您可以进行处理。     ,我见过这个。让我们详细了解一下。要创建自定义选择器视图,请创建自定义UIView类,例如:
@interface TimeAroundView : UIView 
{
    NSString *title;
    UIImage *image;
}
@property (nonatomic,retain) NSString *title;
@property (nonatomic,retain) UIImage *image;
@end
然后在自定义选择器视图控制器中创建一些容器,例如NSArray,它将获取您要在选择器视图中表示的所有TimeAroundView对象。因此,对于每个对象,您必须执行
timeAroundViewObject.userInteractionEnabled = NO;
我认为-(id)init是填充该容器的最佳位置,因此您会得到以下信息:
- (id)init
{
    self = [super init];
    if (self) {
        // create the data source for this custom picker
        NSMutableArray *viewArray = [[NSMutableArray alloc] init];

        TimeAroundView *earlyMorningView = [[TimeAroundView alloc] initWithFrame:CGRectZero];
        earlyMorningView.title = @\"Early Morning\";
        earlyMorningView.image = [UIImage imageNamed:@\"12-6AM.png\"];
        earlyMorningView.userInteractionEnabled = NO;
        [viewArray addObject:earlyMorningView];
        [earlyMorningView release];

        TimeAroundView *lateMorningView = [[TimeAroundView alloc] initWithFrame:CGRectZero];
        lateMorningView.title = @\"Late Morning\";
        lateMorningView.image = [UIImage imageNamed:@\"6-12AM.png\"];
        lateMorningView.userInteractionEnabled = NO;
        [viewArray addObject:lateMorningView];
        [lateMorningView release];

        // ....  (more of objects)

        self.customPickerArray = viewArray;
        [viewArray release];
    }

    return self;
}
并且在您的pickerView:viewForRow:forComponent:reusingView:中,您只需从数组中返回适当的元素。 这对我行得通。     

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...