Flutter - iOS Native Side Navigation Controller

1k Views Asked by At

In my Flutter project, my goal was to redirect to iOS native side and I have done this. 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 Image

AppDelegate Page Code

What I did so far is:

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 - In AppDelegate, I did change the NavigationBarHidden to false and it starts show every where in the app.

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

1

There are 1 best solutions below

0
dengST30 On

I think NavigationBar have shown. While it's backgroundColor is nil.

Since UINavigationController is a native controller, it is easy to debug its view hierarchy.

111

The left side is its simulator. The background is the Xcode debugger.

Here is my case solved:


@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)
  }
}