【问题标题】:Why can't I see the navigation back button on the iOS?为什么我在 iOS 上看不到导航返回按钮?
【发布时间】:2019-09-06 12:46:38
【问题描述】:

我是 iOS 开发的初学者。移动屏幕时出现问题。我单击故事板上的按钮,然后用鼠标右键拖动它,然后单击要移动的视图控制器。但是,按下按钮时,导航返回按钮不可见。是什么原因?

Main.storyboard

手机

按下右下方黄色按钮时移动。

按下右下方的黄色按钮时移动。我的右键不是“条形按钮项”,而只是一个按钮。原因是“条形按钮”不是我想要的。

************************ 编辑开始 ********************* ***************

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if segue.identifier == "goAgreeScreen" {
            performSegue(withIdentifier: "goAgreeScreen", sender: self) // get Error

        } else if segue.identifier == "otherScreen" {

        }
    }

错误是Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ffee5677ff8)

************************ 编辑结束 ********************* ***************

************************编辑了两个************************** *****************

移动主屏幕按钮

   @IBAction func Onclick(_ sender: Any) {
        AVCaptureDevice.requestAccess(for: AVMediaType.video) { response in
            if response {
                print(response , ": granted")
                let center = UNUserNotificationCenter.current()
                // Request permission to display alerts and play sounds.
                center.requestAuthorization(options: [.alert, .sound])
                { (granted, error) in
                    if granted {
                        print(granted, ": is granted")
                        DispatchQueue.main.async { self.moveScreen()}
                    } else {
                        print(granted, ": is not granted")
                        DispatchQueue.main.async { self.moveScreen()}
                    }
                }
            } else {
                print(response , ": not granted")
                let center = UNUserNotificationCenter.current()
                // Request permission to display alerts and play sounds.
                center.requestAuthorization(options: [.alert, .sound])
                { (granted, error) in
                    if error == nil {
                        if granted == true {
                             print(granted, ": is granted")
                            DispatchQueue.main.async { self.moveScreen()}
                        }
                        else {
                            print(granted, ": is not granted")
                            DispatchQueue.main.async { self.moveScreen()}
                        }
                    } else {
                        print(error as Any)
                        }
                }
            }
        }
    }

************************已编辑两端 ************************* ******************

【问题讨论】:

  • 当您在带有黄色按钮的屏幕上时,您是否看到手机上的“主要”标题?如果没有,您可能访问了 viewController 而没有将它嵌入到 navigationController
  • 是的。我什至看不到缅因州。你是什​​么意思将它添加到导航控制器?如何添加?
  • 取决于您如何显示第一页。如果你是通过故事板做的,点击导航控制器并勾选“是初始视图控制器”,导航控制器旁边会出现一个箭头。然后,当您打开应用程序时,它应该位于导航控制器内,您将看到“主”标题和后退按钮。
  • @Daniel 从我的故事板上的图片中可以看到,它已连接到屏幕你能看看我编辑的问题吗?
  • Ansersion 下面的回答是一个很好的参考;如果你回顾一下,你会看到需要做什么。您不应该将 performSegue 命令放在 prepare(for segue) 函数中,这可能是导致错误的原因(如果您使用情节提要,则不需要 performSegue)。也不太清楚“它已连接到屏幕”是什么意思?

标签: ios swift xcode


【解决方案1】:

您是否以编程方式呈现 ViewController?似乎没有显示导航栏。 也许你必须在 IBAction 中展示 if。创建它连接一个按钮。将标识符设置为 segue(在情节提要上)并调用它:

performSegue(withIdentifier: "myIdentifier", sender: self)

【讨论】:

  • 你的意思是当你按下按钮时你必须做一个事件?
【解决方案2】:

【讨论】:

  • 从我的故事板上的图片中可以看出,它已连接到屏幕
  • 但我没有看到主标题,也没有看到后退按钮。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-06
  • 2012-12-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多