JohnnyDark / IOS_Checklist

0 stars 0 forks source link

UINavigationController #3

Open JohnnyDark opened 3 years ago

JohnnyDark commented 3 years ago

作用:按结构层次将多个屏幕组织起来并管理各个屏幕之间切换的操作

JohnnyDark commented 3 years ago

功能使用

  1. 给已有view cotroller添加navigation controller
  2. 设置navigation bar title
  3. navigation item对象:title 和 buttons
  4. 显示large title:navigationController?.navigationBar.prefersLargeTitles = true
  5. navigation hierarchy中的view controller都持有对这个navigation controller的引用,属性名:navigationController(可选类型)
  6. 使用Bar Button Item按钮,实现添加cell功能
  7. 设计segue
  8. 设置smaller title: Large Title下拉选项中选择 Never (viewDidLoad方法中添加:navigationItem.largeTitleDisplayMode = .never)
  9. 释放当前显示的view controller:navigationContrller?.popViewController(animated: true)
  10. 显示隐藏navigation bar: navigationController?.isNavigationBarHidden = true/fasle (可分别放在:viewWillAppear和viewWillDisappear中)
JohnnyDark commented 3 years ago

segue种类:

  1. Show:在navigation stack的顶层push一个view controller,如果view controller不在navigation controller中则 present modally
  2. Show Detail:应用在split view controller中, 两列模式中,新的vc会替换detail vc, 单列中,push 一个navigation controller
  3. Present Modally:新vc将覆盖旧vc,iphone上会覆盖整个屏幕,ipad上在屏幕中间显示一个窗口,显示黑色遮罩,将正在显示的vc遮挡,navigation bar或者tab bar都会被遮挡
  4. Present as Popover:ipad上会popover显示新的vc,点击popover以外区域会dismiss,iphone上新vc modally显示遮挡整个屏幕
  5. Custom:自己定义segue,并控制它的行为
JohnnyDark commented 3 years ago

1.设置navigation controller的root view controller 2.navigation controller中手动执行 manul-segue 通过tableView的didSelectRowAt方法执行 performSegue(withIdentifier:sender)实现segue