当尝试呈现ViewController时,在本机模块上会崩溃。
以下是本机端的代码。
@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)
}
}坠毁的人说
'Application tried to present modally an active controller <UIViewController: 0x7fb09441e620>`我试着在主线程上调用它,但没有成功
发布于 2018-03-11 19:14:35
您正在尝试呈现vc,它已经嵌入到您的navigationController中。因此,你应该展示navigationController,而不是vc。
rootViewController?.present(navigationController, animated: true, completion: nil)https://stackoverflow.com/questions/44355865
复制相似问题