gpt4 book ai didi

ios - UIPickerView 选择指示器在 iOS10 中不可见

转载 作者:IT王子 更新时间:2023-10-29 08:21:47 26 4
gpt4 key购买 nike

我在 Xcode 8 中构建我的项目。UIPickerView 分隔线在 iOS 10 模拟器和设备中不可见,但在 iOS 9.3 设备和模拟器上工作正常。我试图调整 UIPickerView 背景颜色、自动布局和 XIB 中的所有可能,但没有任何效果。有人对此有想法吗?

这是一个包含 UIPickerView 的自定义 View

enter image description here

-(void)layoutSubviews{
isShown = NO;
[super layoutSubviews];

//self.selectedDic = nil;

self.doneBtn.tintColor = COLOR_DB3535;
self.pickerView.backgroundColor = COLOR_DEDEDE;
self.pickerView.showsSelectionIndicator = YES;

[self.doneBtn setTitle:NSLocalizedString(@"App_Generic_Button_Text_Done", @"")];
}


-(UIView*)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
label.tintColor = [UIColor clearColor];
label.backgroundColor = [UIColor yellowColor];
label.textColor = COLOR_666;
label.font = [FontsManager getFONT_ROBOTO_LIGHT_16];
label.textAlignment = NSTextAlignmentCenter;
NSDictionary *dict = [dataArray objectAtIndex:row];
label.text = @"Test";
return label;
}

最佳答案

当我为 iOS10 重建几个解决方案并在模拟器和设备上部署到 iOS10 时,我确实遇到了这个问题。

在我的案例中,我将问题缩小为在初始化期间在选择器中选择一个项目。 IE。我填充了我的选择器,如果我们已经选择了这个属性,那么我会预选它并且出现这些行。我在设置选择器的初始化期间执行此操作。

因此,我的解决方法(适用于我的用例)是在没有现有值的情况下选择 0 元素。

objective-C

UIPickerView *pickerView;

...

[pickerView selectRow:0 inComponent:0 animated:YES];

swift

let pickerView: UIPickerView

...

pickerView.selectRow(0, inComponent: 0, animated: true)

这对我的解决方案来说很好,因为我在设置时有效地选择了第 0 行。

我还没有机会深入研究推理或寻找更清晰的解决方案,但既然我已经解决了我的问题,我想我会在这里分享它,以尽可能地帮助大家。

关于ios - UIPickerView 选择指示器在 iOS10 中不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39564660/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com