【问题标题】:Reliable way to close an app on the iPhone Simulator while working with React Native使用 React Native 时在 iPhone 模拟器上关闭应用程序的可靠方法
【发布时间】:2018-12-05 16:34:40
【问题描述】:
正如this question 指出的那样,按两次 cmd+shift+H 或按两次主页按钮应该打开应用程序轮播,向上滑动应该关闭应用程序。
但我发现自己按了多次,而轮播只显示了大约一半的时间。其他时候连续按 5 次就会出现。有时它只是进入主屏幕,只有当我再次进入应用程序并从那里执行时才有效。我想知道,除了求助于这种巫术之外,还有其他可靠的方法吗? ;-)
如果有任何意义,我正在与react-native storybook 合作:
npm run storybook
我正在使用 iPhone 6 plus 模拟器,所以 iPhone X 模拟器向上滑动对我来说不是一个选项。
【问题讨论】:
标签:
react-native
ios-simulator
【解决方案1】:
从终端:
xcrun simctl terminate [device name] [bundle id]
例如:
xcrun simctl terminate "iPhone 8 Plus" org.reactjs.native.example.layout"
或
添加到 package.json:
"close": "xcrun simctl terminate \"iPhone 8 Plus\" org.reactjs.native.example.layout",
然后运行:
npm run close