在选项卡控制器中嵌入导航控制器会隐藏视图控制器中的导航项

时间:2016-02-20 03:45:10

标签: ios objective-c swift

结构就像这样

标签栏控制器 - >导航栏(项目) - >视图控制器(右侧有一些按钮。

在视图控制器中,导航栏的属性从以下位置加载:

<canvas id="canvas" width=300 height=300></canvas>

当我只使用导航栏时它工作正常,但现在导航栏正在被空白导航栏取代。导航栏上有两个按钮,当我运行代码时,它没有显示。我试图通过override func viewWillAppear(animated: Bool) { currentUserId = PFUser.currentUser()!.objectId! as String self.navigationController?.setToolbarHidden(true, animated: true) if (isSegue == "CurrentUser") { UserId = PFUser.currentUser()!.objectId! as String self.navigationItem.title = "My Album" } else { self.navigationItem.title = userName self.navigationItem.rightBarButtonItems = nil } //added to make navigation bar black - Subodh let nav = self.navigationController?.navigationBar var image = UIImage(named: "xxxxxxx") image = image?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) self.navigationItem.leftBarButtonItem = UIBarButtonItem(image: image, style: UIBarButtonItemStyle.Done, target: self, action: "leftBarButtonPressed") nav?.barStyle = UIBarStyle.Black nav?.tintColor = UIColor.whiteColor() self.navigationController!.toolbar.barTintColor = UIColor.blackColor(); self.navigationController?.hidesBarsOnTap = false self.tabBarController?.hidesBottomBarWhenPushed = true self.collectionView.reloadData() } 从标签视图控制器隐藏导航栏,但它不起作用。对于tabcontroller,我只能设置标题而不是其他东西。那我怎么办呢?

1 个答案:

答案 0 :(得分:0)

通过在viewdidload中包含它来实现它:

self.tabBarController?.navigationController?.navigationBarHidden = true