Skip to content

Commit 0096a16

Browse files
authored
fix(ios): Set delegate properly in new architecture to resolve question marks display issue (#640)
1 parent b7efb65 commit 0096a16

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

ios/RNCPicker.mm

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ @implementation RNCPicker
2020

2121
- (instancetype)initWithFrame:(CGRect)frame
2222
{
23-
if ((self = [super initWithFrame:frame])) {
24-
_color = [UIColor blackColor];
25-
_font = [UIFont systemFontOfSize:21]; // TODO: selected title default should be 23.5
26-
_selectedIndex = NSNotFound;
27-
_textAlign = NSTextAlignmentCenter;
28-
_numberOfLines = 1;
29-
#ifdef RCT_NEW_ARCH_ENABLED
30-
// nothing
31-
#else
32-
self.delegate = self;
33-
#endif
34-
self.dataSource = self;
35-
[self selectRow:0 inComponent:0 animated:YES]; // Workaround for missing selection indicator lines (see https://stackoverflow.com/questions/39564660/uipickerview-selection-indicator-not-visible-in-ios10)
36-
}
23+
self = [super initWithFrame:frame];
24+
if (!self) return nil;
25+
26+
_color = [UIColor blackColor];
27+
_font = [UIFont systemFontOfSize:21]; // TODO: selected title default should be 23.5
28+
_selectedIndex = NSNotFound;
29+
_textAlign = NSTextAlignmentCenter;
30+
_numberOfLines = 1;
31+
32+
self.delegate = self;
33+
self.dataSource = self;
34+
35+
[self selectRow:0 inComponent:0 animated:YES]; // Workaround for missing selection indicator lines (see https://stackoverflow.com/questions/39564660/uipickerview-selection-indicator-not-visible-in-ios10)
36+
3737
return self;
3838
}
3939

@@ -118,13 +118,7 @@ - (UIView *)pickerView:(UIPickerView *)pickerView
118118
RNCPickerLabel* label = view.subviews[0];
119119
label.font = _font;
120120

121-
label.textColor =
122-
#ifdef RCT_NEW_ARCH_ENABLED
123-
_items[row][@"textColor"]
124-
#else
125-
[RCTConvert UIColor:_items[row][@"textColor"]]
126-
#endif
127-
?: _color;
121+
label.textColor = [RCTConvert UIColor:_items[row][@"textColor"]] ?: _color;
128122

129123
label.textAlignment = _textAlign;
130124
label.text = [self pickerView:pickerView titleForRow:row forComponent:component];

0 commit comments

Comments
 (0)