我正在尝试使用React本机-选择选择无头组件的iOS和安卓。根据医生发现的这里
您可以传递子组件(例如自定义按钮或输入),以便组件包装(同时适用于iOS和Android )。
下面是我的代码示例:
import React, { Component } from 'react';
import {
View,
Text,
} from 'react-native';
import RNPickerSelect from 'react-native-picker-select';
<View style={{flex:1}}>
<RNPickerSelect
placeholder={{}}
items={MyList}
onValueChange={(itemValue, itemIndex) => {
console.log('itemValue')
}}
style={{...pickerSelectStyles}}
>
<View style={{backgroundColor:'purple', flex:1, justifyContent:'center', alignItems:'center'}}>
<Text>
Test Text where I should be able to touch to get things to happen
</Text>
</View>
</RNPickerSelect>
const pickerSelectStyles = StyleSheet.create({
headlessAndroidContainer: {
flex:1
}
});
<View style={{height:height * 0.5}}>
<Text>test</Text>
</View>
</View>
const pickerSelectStyles = StyleSheet.create({
viewContainer: {
flex:1,
backgroundColor: 'purple',
},
headlessAndroidContainer: {
backgroundColor: 'purple',
flex:1
}
});我期待的是,在我的屏幕上,我看到了两个部分,一半紫色,一半白色。紫色部分的文字说事情应该发生,白色部分应该进行测试。我应该可以点击任何地方的紫色部分和我的选择与MyList应该会出现。
这在模拟器上可以正常工作,但在真正的android设备上却不起作用。在一个真正的设备上,我似乎可以点击紫色区域,而采摘者偶尔也会出现。如能提供任何帮助,将不胜感激!
编辑:忘记提到这是一个具体的android问题,它工作在真实的和模拟的iPhones。
发布于 2018-10-28 17:56:25
似乎RNPickerselect封装在TouchableWithoutFeedback中是因为某种原因而中断的,一旦超出该标记,它就会正常工作。
发布于 2018-10-26 19:37:14
添加最新版本(5.0版)似乎解决了此问题。我添加的版本是4.4,我在10天前将它添加到了我的项目中。最新版本大约在一周前发布,似乎解决了这个问题。
https://stackoverflow.com/questions/53014552
复制相似问题