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

发布于 2024-11-10 06:11:44 字数 73 浏览 1 评论 0原文

当我在修改后的选择器视图中选择一个单元格时,会出现蓝色背景颜色。 我见过的所有其他踏板都没有给我一个很好的答案。 有人有解决办法吗?

when i select a cell in my modified picker view, a blue background colour appears.
all other treads i have seen do not give me a good answer.
anyone has a solution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

过期以后 2024-11-17 06:11:44

pickerView.showsSelectionIndicator = NO;

pickerView.showsSelectionIndicator = NO;

£烟消云散 2024-11-17 06:11:44

只需将 UITableViewCell SelectionStyle 属性设置为 UITableViewCellEditingStyleNone

cell.selectionStyle = UITableViewCellEditingStyleNone;

Just set the UITableViewCell selectionStyle property to UITableViewCellEditingStyleNone

cell.selectionStyle = UITableViewCellEditingStyleNone;
离不开的别离 2024-11-17 06:11:44

我在选择器视图的顶部添加了工具栏,并将自定义按钮添加为工具栏的子视图,并且选择器视图和工具栏都添加为主视图的子视图,以便您可以处理此问题。

I have add toolbar at the top of picker view and add cutom button as a sub view of toolbar and both picker view and toolbar are add as a subview of Main view so you can handle this.

孤城病女 2024-11-17 06:11:44

我就遇到过这个人。让我们详细看看吧。要创建自定义选择器视图,您需要创建自定义 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: 您只需从数组返回正确的元素。
这对我有用。

I've met this one. Let's get a look at it in details. To create your custom picker view, you create your custom UIView class, e.g. :

@interface TimeAroundView : UIView 
{
    NSString *title;
    UIImage *image;
}
@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) UIImage *image;
@end

Then in your custom picker view controller you create some container, e.g. NSArray, which will get all TimeAroundView objects you want to represent in your picker view. So, for every object you must do

timeAroundViewObject.userInteractionEnabled = NO;

I think -(id)init is the best place for filling that container in, so you get something like this:

- (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;
}

And in your pickerView:viewForRow:forComponent:reusingView: you just return proper element from array.
That works for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文