如何避免冻结ios上的本机应用程序警报?

时间:2019-06-11 18:38:59

标签: ios react-native alert freeze

警报最近停止在IOS上处理我所有的本机应用程序。除了更新依赖项外,我没有做任何其他更改。他们仍然可以在android上正常工作。具体来说,警报弹出,但随后将警报框上的按钮分隔开的条随机闪烁,并且所有内容均冻结。大约在同一时间,我还必须为所有我的本机应用程序更新代码,以实现Picker在android上的行为方式。可能是巧合,还是同一更新引起的?我同时更新了所有依赖项,因此如果这是一个问题,我不确定是哪个。

发生这种情况:

  • 无论页面上是否有模式组件。

  • 无论我使用的是JavaScript警报还是react-native的Alert组件,还是react-native的AlertIOS组件。

这只是我在测试页上使用的官方react-native文档的副本和粘贴:

// Works on both iOS and Android
Alert.alert(
  'Alert Title',
  'My Alert Msg',
  [
    {text: 'Ask me later', onPress: () => console.log('Ask me later pressed')},
    {
      text: 'Cancel',
      onPress: () => console.log('Cancel Pressed'),
      style: 'cancel',
    },
    {text: 'OK', onPress: () => console.log('OK Pressed')},
  ],
  {cancelable: false},

);

对应用程序1的依赖关系

  "dependencies": {
    "@react-native-community/cameraroll": "^1.0.3",
    "@react-native-community/netinfo": "^2.0.4",
    "react": "16.8.3",
    "react-native": "0.59.5",
    "react-native-elements": "^1.1.0",
    "react-native-gesture-handler": "^1.1.0",
    "react-native-print": "^0.5.1",
    "react-native-vector-icons": "^6.4.2",
    "react-navigation": "^3.8.1"
  },
  "devDependencies": {
    "@babel/core": "^7.4.3",
    "@babel/runtime": "^7.4.3",
    "babel-jest": "^24.7.1",
    "jest": "^24.7.1",
    "metro-react-native-babel-preset": "^0.53.1",
    "react-test-renderer": "16.8.3"
  },

对应用2的依赖性

  "dependencies": {
    "@react-native-community/cameraroll": "^1.0.5",
    "@react-native-community/netinfo": "^2.0.10",
    "react": "16.8.3",
    "react-native": "0.59.8",
    "react-native-elements": "^1.1.0",
    "react-native-gesture-handler": "^1.2.1",
    "react-native-vector-icons": "^6.4.2",
    "react-navigation": "^3.10.1"
  },
  "devDependencies": {
    "@babel/core": "^7.4.4",
    "@babel/runtime": "^7.4.4",
    "babel-jest": "^24.8.0",
    "jest": "^24.8.0",
    "metro-react-native-babel-preset": "^0.54.1",
    "react-test-renderer": "16.8.3"
  },

这种情况发生时,我没有收到任何错误消息,并且控制台上没有任何异常出现。另外,按钮没有响应,因此在上面的示例中,单击它们不会将任何内容记录到控制台。

还有其他人遇到这个问题,您找到原因了吗?谢谢!

1 个答案:

答案 0 :(得分:0)

毕竟,只是我不小心按了热键,以在模拟器中播放慢速动画。显然,如果您选择了此更改,则该更改将应用​​于XCode中的所有模拟器,因此切换模拟器无效,因为它们都是XCode的一部分。有关更多详细信息,请参见以下答案:

https://stackoverflow.com/a/35116096/9147743

https://stackoverflow.com/a/38189484/9147743