【发布时间】:2019-10-10 22:15:59
【问题描述】:
我有一个在 Flutter 中开发的应用程序,它有一个 UIViewController 必须在原生 IOS 中实现(没有其他解决方法,这是必须的)
我已经实现了它,它根据第一次测试工作,但我想仔细检查一下你的意见是否还可以,因为我在 Flutter 方面没有那么经验丰富,恐怕有点在我的应用导航堆栈中弄得一团糟,将来可能会导致错误。
所以,我已经通过 MethodChannel 实现了它。我有一个方法,从“Flutter side”调用。我不会在此处粘贴与 MethodChannel 相关的内容,因为它们很琐碎。
在我的 AppDelegate didFinishLaunchingWithOptions 我添加了这个:
let flutterViewController = FlutterViewController()
self.navigationController = UINavigationController(rootViewController: flutterViewController)
self.navigationController?.isNavigationBarHidden = true
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window.rootViewController = self.navigationController
self.window.makeKeyAndVisible()
我的打开方法是这样的:
private func openNativeUI(result: FlutterResult) {
let sb = UIStoryboard(name: "Main", bundle: nil)
let uiController = sb.instantiateViewController(withIdentifier: "nativeui")
self.navigationController?.pushViewController(uiController, animated: true)
result(true)
}
你怎么看?
非常感谢您的任何建议,并提前感谢您的帮助!
【问题讨论】: