嵌入式导航栏在运行时不显示。
Embedded Navigation Bar not showing at runtime.
我在我的 UiTableViewController 中嵌入了一个导航控制器,希望有一个导航栏。导航栏显示在故事板中,但在运行时不显示。有其他人 运行 遇到这个问题并可以提供解决方案吗?我已经阅读了许多 Whosebug 帖子,但找不到关于这个问题的帖子。
您必须呈现普通 table 视图而不是导航控制器。您需要做的是让您table查看导航控制器的根视图并显示导航控制器。
yourTableController *vc = //reference from storyboard
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
//then present the nav instead of tableview.
在Swift中:
var nav: UINavigationController = UINavigationController(rootViewController: vc)
//then present the nav
或者,如果您希望 table 视图作为初始视图控制器,则将您的导航控制器(其根视图是您的 table 视图)作为情节提要中的初始视图控制器。
如果您通过 [编辑器 --> 嵌入 --> 导航控制器 ] 添加了导航栏,那么假设您添加了一个 UIBarButtonItem 名称 forward
你 select 那个项目按钮并将它拖到另一个视图控制器,它会弹出说明你是否想要继续显示等...然后你 select 继续显示。
稍后您决定添加另一个 UIBarButtonItem 说之前,然后将此按钮拖回主视图控制器。
在 运行 时间你现在看到一个白色的空白 space 尝试以下修复
1st) 确保您已在 'Storyboard segue' 中的两个 segue 中进行识别,单击圆圈以到达此区域。
2nd) 删除 segue 而不是导航栏!
3rd) 通过将它拖到控制器来重新创建 segue
问题应该已解决,如果此解决方案有帮助,请打勾。
self.navigationController?.isNavigationBarHidden = false
if let _navigationItem = embeddedViewController?.navigationItem {
self.navigationController?.navigationBar.pushItem(_navigationItem, animated: false)
}
我在我的 UiTableViewController 中嵌入了一个导航控制器,希望有一个导航栏。导航栏显示在故事板中,但在运行时不显示。有其他人 运行 遇到这个问题并可以提供解决方案吗?我已经阅读了许多 Whosebug 帖子,但找不到关于这个问题的帖子。
您必须呈现普通 table 视图而不是导航控制器。您需要做的是让您table查看导航控制器的根视图并显示导航控制器。
yourTableController *vc = //reference from storyboard
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
//then present the nav instead of tableview.
在Swift中:
var nav: UINavigationController = UINavigationController(rootViewController: vc)
//then present the nav
或者,如果您希望 table 视图作为初始视图控制器,则将您的导航控制器(其根视图是您的 table 视图)作为情节提要中的初始视图控制器。
如果您通过 [编辑器 --> 嵌入 --> 导航控制器 ] 添加了导航栏,那么假设您添加了一个 UIBarButtonItem 名称 forward
你 select 那个项目按钮并将它拖到另一个视图控制器,它会弹出说明你是否想要继续显示等...然后你 select 继续显示。
稍后您决定添加另一个 UIBarButtonItem 说之前,然后将此按钮拖回主视图控制器。
在 运行 时间你现在看到一个白色的空白 space 尝试以下修复
1st) 确保您已在 'Storyboard segue' 中的两个 segue 中进行识别,单击圆圈以到达此区域。
2nd) 删除 segue 而不是导航栏!
3rd) 通过将它拖到控制器来重新创建 segue
问题应该已解决,如果此解决方案有帮助,请打勾。
self.navigationController?.isNavigationBarHidden = false
if let _navigationItem = embeddedViewController?.navigationItem {
self.navigationController?.navigationBar.pushItem(_navigationItem, animated: false)
}