首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >调用本机模块并尝试呈现ViewController时,iOS上的React Native崩溃

调用本机模块并尝试呈现ViewController时,iOS上的React Native崩溃
EN

Stack Overflow用户
提问于 2017-06-04 23:47:20
回答 1查看 565关注 0票数 1

当尝试呈现ViewController时,在本机模块上会崩溃。

以下是本机端的代码。

代码语言:javascript
运行
复制
@objc(SomethingManager)
class SomethingManager : NSObject {

@objc(doPresent)
func doPresent() {

  let vc = UIViewController()

  let navigationController = UINavigationController(rootViewController: vc)
  navigationController.setNavigationBarHidden(true, animated: false)


  let rootViewController = UIApplication.shared.keyWindow?.rootViewController
  rootViewController?.dismiss(animated: false, completion: nil)
  rootViewController?.present(vc, animated: true, completion: nil)
 }
}

坠毁的人说

代码语言:javascript
运行
复制
'Application tried to present modally an active controller <UIViewController: 0x7fb09441e620>`

我试着在主线程上调用它,但没有成功

EN

回答 1

Stack Overflow用户

发布于 2018-03-11 19:14:35

您正在尝试呈现vc,它已经嵌入到您的navigationController中。因此,你应该展示navigationController,而不是vc。

代码语言:javascript
运行
复制
rootViewController?.present(navigationController, animated: true, completion: nil)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44355865

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档