[英]How can I open xib(ViewController) in xib(ViewController) when I tap Button without Navigation
[英]How I can use back navigation button in viewcontroller?
大家好:) 我是 iOS 开发的新手,我不知道如何做一件事。 我有这样的视图控制器,它与标签栏 controller 连接:
如您所见,这不是 TableViewController,而是带有表格的普通视图 controller。 在表格中,我有一些单元格,当我按下某个单元格时,我需要使用后退按钮打开另一个视图。 例如,在 android 中,我使用了带有工具栏的对话框片段,其中放置了后退按钮,但正如我所见,在 ios 中,我们没有那样的东西。 I also heard about navigation controller but I think that in such situation it won't help me:( I have such select function for this table in this view controller:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch indexPath.section {
case 0:
print("1")
case 1:
print("1")
case 2:
print("2")
// I need to add it here
case 3:
print("3")
default: break
}
}
所以也许 ios 有一些能力添加工具栏到带有后退按钮的视图控制器没有导航 controller? 我看到我可以将此元素添加到我的视图控制器中,但我无法添加按钮,并且我看到我的工具栏与系统栏重叠:(
所以也许 ios 有一些能力添加工具栏到带有后退按钮的视图控制器没有导航 controller?
不,您要么使用UINavigationController
要么手动添加按钮( UIButton
或UIBarButtonItem
)。
第一个会在您的navigationController's
navigationBar
中自动添加一个后退按钮。
后者需要一个选择器,您将在其中提供您希望如何将 go 返回到上一个屏幕。
还请了解推送/显示和呈现视图控制器之间的区别。
Push/Show --- Pop.
Present --- Dismiss.
我建议 go 通过 iOS 中的导航基础知识。 也许从这里开始: https://www.raywenderlich.com/4284-your-second-swift-4-ios-11-app/lessons/22
基本上,您有两种选择来实现它:
1.1用NavigationController替换你的MoreViewController,然后将你的viewController(里面有表格视图的VC)嵌入到navigationController中。
层次结构将是: TabBar -> NavigationController -> More
1.2 在导航控制器中嵌入 TabBarController。 触发导航步骤更加困难,但它实现了另一个效果: the detail viewController fully overlaps the tabBar
。 这是因为它与 NavigationController 完全重叠,并且 TabBar 在 NavigationController 内部。 对于 1.1,详细视图不与 tabBar 重叠。
层次结构将是: NavigationController -> TabBar -> More
使用什么方法? 这取决于您展示的内容,UX。 如您所见,在 Facebook 应用程序中,有时您会看到 viewController 从下到上显示,有时您会看到 viewController 从右到左显示。 它们不是随机选择。
还有一件事,对于重叠系统状态栏,您应该使用安全布局指南而不是顶部,如: https://medium.com/@hassanahmedkhan/playing-it-safe-with-safe-area-layout-guide- b3f09bdc71fe
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.