React-native-image-viewer: 好像阻止了android 的back键盘监听~

Created on 11 Nov 2016  ·  8Comments  ·  Source: ascoders/react-native-image-viewer

BackAndroid.addEventListener('hardwareBackPress', this.back); 浏览大图的时候监听不了这个

Most helpful comment

@tosslee your solution is perfect. I'll just translate it.

如果是跟例子一样用Modal包着ImageView,给onRequestClose传一个函数控制visible属性就行了

Translation: If you're using a <Modal> just pass it onRequestClose props with your control state boolean toggle function.

Example:

//render 
       <Modal visible={this.state.isFullscreen} transparent={true}
          onRequestClose={() => { this.toggleFullscreen(false) }}>{...}</Modal>

  toggleFullscreen = (val) => {
    this.setState((prevState) => ({
      isFullscreen: val
    }))
  }

All 8 comments

这个插件不会干扰监听物理键的,它只会截断作用范围内UI的手势

是我的问题

是什么问题呢?我也遇到了

什么原因?

我的安卓点击虚拟返回键没有效果

@yuanji123 你是怎么解决的?

如果是跟例子一样用Modal包着ImageView,给onRequestClose传一个函数控制visible属性就行了

@tosslee your solution is perfect. I'll just translate it.

如果是跟例子一样用Modal包着ImageView,给onRequestClose传一个函数控制visible属性就行了

Translation: If you're using a <Modal> just pass it onRequestClose props with your control state boolean toggle function.

Example:

//render 
       <Modal visible={this.state.isFullscreen} transparent={true}
          onRequestClose={() => { this.toggleFullscreen(false) }}>{...}</Modal>

  toggleFullscreen = (val) => {
    this.setState((prevState) => ({
      isFullscreen: val
    }))
  }

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paolospag picture paolospag  ·  4Comments

ganeshhfs picture ganeshhfs  ·  3Comments

nicomontanari picture nicomontanari  ·  5Comments

sfatih picture sfatih  ·  7Comments

chinalwb picture chinalwb  ·  5Comments