簡體   English   中英

Flutter - iOS 原生側導航 Controller

[英]Flutter - iOS Native Side Navigation Controller

在我的 Flutter 項目中,我的目標是重定向到 iOS 本機端,我已經做到了。 After landing on iOS native side, from flutter view controller (A), I can go to view controller (B). After this I decided to add a navigation controller on this page (B) so I Embed in that view controller (B) in a navigation controller but the navigation doesn't showed up after I was in view controller (B).

StoryBoard 圖像

AppDelegate 頁面代碼

到目前為止我所做的是:

1 - Embed in Flutter view controller (A) in a navigation controller [output was: Didn't found flutter view controller when I first run the app]

2 - 在 AppDelegate 中,我確實將 NavigationBarHidden 更改為 false,它開始顯示應用程序中的每個位置。

self.navigationController.setNavigationBarHidden(false, animated: false)

我認為NavigationBar已經顯示。 雖然它的背景顏色為零。

由於UINavigationController是原生的 controller,因此很容易調試其視圖層次結構。

111

左側是它的模擬器。 背景是 Xcode 調試器。

這是我的案例解決了:


@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
      if let ctrl = window.rootViewController as? FlutterBinaryMessenger{
          let methodChannel = FlutterMethodChannel(name: "_PageMineState", binaryMessenger: ctrl)
          methodChannel.setMethodCallHandler { call, handler in
              switch call.method{
              case "pic":
                  if let vc = ctrl as? FlutterViewController{
                      
                      let controllerOne = UIViewController()
                      // bar title
                      controllerOne.navigationControllergationItem.title = "Come"
                      controllerOne.view.backgroundColor = UIColor.red
                      let navigationController = UINavigationController(rootViewController: controllerOne)
                      navigationController.modalPresentationStyle = .fullScreen
                      // To solve it is to add:
                      // bar background color
   navigationController.navigationControllergationBar.backgroundColor = UIColor.white
                      
                      vc.present(navigationController, animated: true) {   }

                  }
              default:()
              }
          }
      }
     return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}


暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM