最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

React Native RNPickerSelect doesn't open on iOS - Stack Overflow

programmeradmin3浏览0评论

All works fine on android but in iOS my picker doesn't open. I have tried to change style, remove style, but nothing works.

My picker :

<View style={[styles.pickerWrapper, styles.marge]}>
                                <RNPickerSelect
                                    placeholder={{}}
                                    onValueChange={(itemValue) => setSelectedTypeTest(itemValue)}
                                    items={Constants.getTypeTest().map((test) => ({
                                        label: t(test.label),
                                        value: test.value,
                                    }))}
                                    style={{
                                        inputAndroid: styles.inputAndroid,
                                        inputIOS: styles.inputIOS,
                                        viewContainer: styles.viewContainer,
                                    }}
                                    value={selectedTypePlanet}
                                    useNativeAndroidPickerStyle={false}
                                    doneText="OK"
                                />
                            </View>

Style for iOS :

inputIOS: {
    height: 30,
    paddingTop: 0,
    paddingBottom: 0,
    justifyContent: 'center',
    alignItems: 'center',
    textAlign: 'center',
    backgroundColor: '#074183',
    color: 'aliceblue',
    borderRadius: 50,
    borderWidth: 1,
    borderColor: 'aliceblue',
    paddingHorizontal: 10,
    lineHeight: 15,
    width: width * 0.4,
    fontWeight: 500,
},

Style for container:

 viewContainer: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    height: 50,
    width: '100%',
},

I have seen on other topics: "overflow: 'hidden'" can resolve it, but don't change something for me.

All works fine on android but in iOS my picker doesn't open. I have tried to change style, remove style, but nothing works.

My picker :

<View style={[styles.pickerWrapper, styles.marge]}>
                                <RNPickerSelect
                                    placeholder={{}}
                                    onValueChange={(itemValue) => setSelectedTypeTest(itemValue)}
                                    items={Constants.getTypeTest().map((test) => ({
                                        label: t(test.label),
                                        value: test.value,
                                    }))}
                                    style={{
                                        inputAndroid: styles.inputAndroid,
                                        inputIOS: styles.inputIOS,
                                        viewContainer: styles.viewContainer,
                                    }}
                                    value={selectedTypePlanet}
                                    useNativeAndroidPickerStyle={false}
                                    doneText="OK"
                                />
                            </View>

Style for iOS :

inputIOS: {
    height: 30,
    paddingTop: 0,
    paddingBottom: 0,
    justifyContent: 'center',
    alignItems: 'center',
    textAlign: 'center',
    backgroundColor: '#074183',
    color: 'aliceblue',
    borderRadius: 50,
    borderWidth: 1,
    borderColor: 'aliceblue',
    paddingHorizontal: 10,
    lineHeight: 15,
    width: width * 0.4,
    fontWeight: 500,
},

Style for container:

 viewContainer: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    height: 50,
    width: '100%',
},

I have seen on other topics: "overflow: 'hidden'" can resolve it, but don't change something for me.

Share Improve this question edited Mar 31 at 13:53 tommat208 1511 silver badge11 bronze badges asked Mar 31 at 10:47 yggdraes13yggdraes13 759 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I haven't solved the problem, but I found a workaround that works well:

react-native-dropdown-picker

发布评论

评论列表(0)

  1. 暂无评论