转到 UINavigationController 但 rootViewController 之后的子 UIViewController 没有导航栏 SWIFT
Segue to UINavigationController but Children UIViewControllers after rootViewController have no Navigation Bar SWIFT
我正在制作一个 swift 应用程序,我从 UIViewController(我的登录屏幕)转到具有根视图的 UINavigationController(主屏幕 post 登录)。这一切都很好,所有必要的数据都传递到根视图。我的问题是,在我单击 UITableViewController 上的一个单元格后,它会将我带到下一个 UIViewController 但是 没有导航栏(所以我不能返回)。
我也尝试取消隐藏导航栏但没有成功,我真的认为它不在那里。
我不确定这些是否是导致问题的原因的提示,但这是我在调试器中收到的一些警告
Warning messages
这是我的故事板的结构
My storyboard
这是我从登录到主屏幕的代码
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "segueToTeams" {
if let user = self.user{
let navController = segue.destinationViewController as! UINavigationController
let welcomeView = navController.topViewController as! TeamsTableViewController
welcomeView.user = user
}
}
}
func goToTeamsView(storyBoard : UIStoryboard){
let welcomeView = storyBoard.instantiateViewControllerWithIdentifier("teamsView")
let navigationController = UINavigationController(rootViewController: welcomeView)
super.performSegueWithIdentifier("segueToTeams", sender: self)
super.presentViewController(navigationController, animated: true, completion: nil)
}
最后是我的代码,用于从 UINavigationViewController 的根视图控制器(Select 故事板屏幕截图中的团队视图)到应该具有导航的下一个(单个团队视图控制器)酒吧但没有
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
performSegueWithIdentifier("selectTeamCellSegue", sender: indexPath.row)
}
如果您需要任何其他信息,请告诉我。我为这个问题苦苦挣扎的时间比我想承认的要长,任何 help/advice 将不胜感激!
您可以通过 select 将您的视图控制器嵌入到导航控制器中,然后 select "Edit" -> "Embed in" -> "Navigation Controller"。然后您可以添加 BarButtonItems 来回移动。我猜你正在使用模态转场?据我所知,这样您的视图控制器不会自动嵌入到您的初始导航控制器中。
希望对您有所帮助
我正在制作一个 swift 应用程序,我从 UIViewController(我的登录屏幕)转到具有根视图的 UINavigationController(主屏幕 post 登录)。这一切都很好,所有必要的数据都传递到根视图。我的问题是,在我单击 UITableViewController 上的一个单元格后,它会将我带到下一个 UIViewController 但是 没有导航栏(所以我不能返回)。
我也尝试取消隐藏导航栏但没有成功,我真的认为它不在那里。
我不确定这些是否是导致问题的原因的提示,但这是我在调试器中收到的一些警告 Warning messages
这是我的故事板的结构 My storyboard
这是我从登录到主屏幕的代码
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "segueToTeams" {
if let user = self.user{
let navController = segue.destinationViewController as! UINavigationController
let welcomeView = navController.topViewController as! TeamsTableViewController
welcomeView.user = user
}
}
}
func goToTeamsView(storyBoard : UIStoryboard){
let welcomeView = storyBoard.instantiateViewControllerWithIdentifier("teamsView")
let navigationController = UINavigationController(rootViewController: welcomeView)
super.performSegueWithIdentifier("segueToTeams", sender: self)
super.presentViewController(navigationController, animated: true, completion: nil)
}
最后是我的代码,用于从 UINavigationViewController 的根视图控制器(Select 故事板屏幕截图中的团队视图)到应该具有导航的下一个(单个团队视图控制器)酒吧但没有
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
performSegueWithIdentifier("selectTeamCellSegue", sender: indexPath.row)
}
如果您需要任何其他信息,请告诉我。我为这个问题苦苦挣扎的时间比我想承认的要长,任何 help/advice 将不胜感激!
您可以通过 select 将您的视图控制器嵌入到导航控制器中,然后 select "Edit" -> "Embed in" -> "Navigation Controller"。然后您可以添加 BarButtonItems 来回移动。我猜你正在使用模态转场?据我所知,这样您的视图控制器不会自动嵌入到您的初始导航控制器中。
希望对您有所帮助