Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/107.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用MMDrawerController时导航栏项目消失_Ios_Swift - Fatal编程技术网

Ios 使用MMDrawerController时导航栏项目消失

Ios 使用MMDrawerController时导航栏项目消失,ios,swift,Ios,Swift,我正在使用MMDrawerController浏览我的应用程序中的各种视图,其中一个是TabBarController,它还有5个视图链接到5个条形图项目中的每一个。这5个视图中的每个视图都附加了导航栏项。这5个视图中的每个视图上的左栏项目切换LeftViewController(我用作抽屉的视图)。我在我的AppDelegate中使用此代码来实现此目的 let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: n

我正在使用MMDrawerController浏览我的应用程序中的各种视图,其中一个是TabBarController,它还有5个视图链接到5个条形图项目中的每一个。这5个视图中的每个视图都附加了导航栏项。这5个视图中的每个视图上的左栏项目切换LeftViewController(我用作抽屉的视图)。我在我的AppDelegate中使用此代码来实现此目的

let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)

    var centerViewController = mainStoryboard.instantiateViewControllerWithIdentifier("TabBarController") as! TabBarController

    var leftViewController = mainStoryboard.instantiateViewControllerWithIdentifier("LeftViewController") as! LeftViewController

    var leftsideNav = UINavigationController(rootViewController: leftViewController)
    var centerNav = UINavigationController(rootViewController: centerViewController)

    centerContainer = MMDrawerController(centerViewController: centerViewController, leftDrawerViewController: leftViewController)

    centerContainer!.closeDrawerGestureModeMask = MMCloseDrawerGestureMode.PanningCenterView
当点击5个ViewController上的左栏按钮时,我调用这个方法

@IBAction func leftButtonTapped(sender: AnyObject) {

    var appDelegate:AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
    appDelegate.centerContainer!.toggleDrawerSide(MMDrawerSide.Left, animated: true, completion: nil)
}
到目前为止效果很好

现在,我的LeftViewController中有一个tableView,我希望在其中实现以下行为-单击第一行将我们导航到TabBarController,而第二行将我们带到另一个ViewController,并将
withFullCloseAnimation
设置为
true

以下是LeftViewController的tableView的
didSelectRowatingIndexPath
方法中的代码

var appDelegate:AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate

        let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)

        var centerViewController = mainStoryboard.instantiateViewControllerWithIdentifier("TabBarController") as! TabBarController
        var centerNav = UINavigationController(rootViewController: centerViewController)

        appDelegate.centerContainer?.setCenterViewController(centerNav, withFullCloseAnimation: true, completion: nil)
        appDelegate.centerContainer!.toggleDrawerSide(MMDrawerSide.Left, animated: true, completion: nil)
        break;
这将使TabBarController中5个视图的导航栏项消失。如果我用这个,效果很好-

var appDelegate:AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
        appDelegate.centerContainer!.toggleDrawerSide(MMDrawerSide.Left, animated: true, completion: nil)

        break;
  • 最后一段代码让我觉得它是在重新启动TabBarController,而不是“恢复”已经初始化的。是这样吗

  • 实现这一目标的正确方法应该是什么


  • 对不起,问题太长了(只是通过键入此进一步增加了问题的长度)

    我添加了。navigationController

    在didSelectRowAtIndexPath索引中(XPath:NSIndexPath)

    appDelegate.centerContainer!。centerViewController centerViewController.navigationController

            break;