[英]onPress not working in menu for ios devices
我想提到的是,此問題僅發生在ios設備上,而android只能正常工作。
我有菜單userMenu類
import Menu, {MenuItem, MenuDivider} from 'react-native-material-menu';
class UserMenu extends React.Component {
logout() {
this.props.logout().then(() => {
this.props.navigation.navigate('Auth')
})
}
render() {
return (
<React.Fragment>
<Menu
ref={ref => this._menu = ref}
button={
<Text
style={{padding: 15}}
onPress={() => {
this._menu.show()
}}>
<FontAwesome5 name={'caret-down'} color={'#fff'} size={25}/>
</Text>
}
>
<MenuItem disabled={true}>{this.props.auth.user.customer.name}</MenuItem>
<MenuDivider/>
<MenuItem
onPress={() => {
this._customerProfile.show();
this._menu.hide();
}}>
<FontAwesome5 name={'cog'}/> Settings
</MenuItem>
<MenuItem
onPress={this.logout.bind(this)}>
<FontAwesome5 name={'sign-out-alt'}/> Logout
</MenuItem>
</Menu>
<CustomerProfile
onRef={ref => this._customerProfile = ref}
/>
</React.Fragment>
)
}
};
如果我單擊菜單中的設置,則會調用this._customerProfile.show()
也是this._menu.hide()
菜單隱藏,但customerProfile無法顯示。 如果我在Menu之外接受菜單項,則顯示customerProfile。
知道什么會導致此問題嗎?
您應該使用TouchableOpacity
renderButton: function() {
return (
<TouchableOpacity onPress={this._onPressButton}>
<Image
style={styles.button}
source={require('./myButton.png')}
/>
</TouchableOpacity>
);
},
參考鏈接
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.