【问题标题】:Creating a segue from tableViewController is adding a navigation bar in destination viewController从 tableViewController 创建一个 segue 是在目标 viewController 中添加一个导航栏
【发布时间】:2019-01-20 06:22:27
【问题描述】:

请看下面的两张图片,一张在添加 segue 之前,一张在添加 segue 之后。请注意目标视图控制器顶部的额外导航栏。我不要那个。为什么要添加它?如何删除它,同时仍然保持 segue?

转场前

转场之后

【问题讨论】:

    标签: swift xcode segue


    【解决方案1】:

    另外一种方法是改变你呈现segue的方式。将种类更改为:Present Modally

    【讨论】:

    • 谢谢。这行得通。上述两种解决方案不起作用,因为我仍然需要原始导航栏在两个控制器中都可见,如图像“segue 之前”所示
    【解决方案2】:

    选择导航控制器并在属性部分检查隐藏导航栏

    【讨论】:

      【解决方案3】:

      从界面生成器中选择控制器并取消选择显示的avbar,它将不再可见 这个也可以试试

      override func viewWillAppear(_ animated: Bool) {
          super.viewWillAppear(animated)
      
          // Hide the navigation bar on the this view controller
          self.navigationController?.setNavigationBarHidden(true, animated: animated)
      }
      
      override func viewWillDisappear(_ animated: Bool) {
          super.viewWillDisappear(animated)
      
          // Show the navigation bar on other view controllers
          self.navigationController?.setNavigationBarHidden(false, animated: animated)
      }
      

      【讨论】:

        猜你喜欢
        • 2015-11-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-01-26
        • 1970-01-01
        • 2020-11-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多