首页 > 解决方案 > 浮动面板。面板内导航

问题描述

我是 IOS 的新手,正在为我的项目使用FloatingPanel。我花了很多时间来了解如何在 FloatingPanel 中创建导航

例如像这样

我的代码

主视图控制器

    var fp: FloatingPanelController?
    fp = FloatingPanelController()
    fp?.delegate = self
    fp?.contentInsetAdjustmentBehavior = .never

// get first child view controller
if let child1ViewController = coordinator?.getChild1ViewController() {
     fp?.set(contentViewController: child1ViewController)
     self.present(fp!, animated: true, completion:nil )
}

Child1ViewController

class Child1ViewController: UIViewController{
    
// some code    

    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    @IBAction func next(_ sender: Any) {
// error here, self.navigationController is nil
        coordinator?.showChild2ViewController(navigationController: self.navigationController!)
    }
}

协调员

func showChild2ViewController(navigationController: UINavigationController) {
    let viewСontroller = Child2ViewController.instantiate(storyboardName: stroryboardName)
    navigationController.pushViewController(viewСontroller, animated: true)
}

标签: iosswift

解决方案


推荐阅读