【发布时间】:2020-03-11 14:35:21
【问题描述】:
我使用 React Native 中的 onpress 方法调用一个函数。 OnPress 无法在 Android 上运行,而在 iOS 上运行顺畅。当我在其他地方尝试 onPress 时它可以工作,但是当我单击图像时,onPress 不起作用。
export default class HomeScreen extends Component {
onBildirim() {
this.props.navigation.navigate("notification", {
title: "notification"
});
}
<View style={styles.footerBody}>
<Image
source={require('../images/footer.png')}
style={{
width:screenWidth,
height:110,
bottom:0,
position: 'absolute'}}
/>
<TouchableHighlight onPress={() => this.onBildirim()}>
<Image
source={require('../images/haberlerbutton2.png')}
style={{
width:35,
height:35,
position: 'absolute',
top:30,
left:20 }}
/>
</TouchableHighlight>
<Text style={{
width:55,
height:35,
position: 'absolute',
top:65,
left:20,
fontSize: 11,
fontFamily: 'ProximaNova-Light' }} >Haberler</Text>
<TouchableHighlight onPress={() => this.onBildirim()}>
<Image
source={require('../images/canlıyayın.png')}
style={{
width:35,
height:35,
top:30,
position: 'absolute',
right:20 }}
/>
</TouchableHighlight>
}
【问题讨论】:
-
试试 touchableOpacity for Android 吧。
-
不工作 touchableOpacity
-
您是否尝试为可触摸的不透明度样式添加更高的 z 索引?试试这个并添加背景颜色,看看它是否被覆盖
标签: react-native