为什么在iOS上看不到导航后退按钮?

时间:2019-09-05 09:37:16

标签: ios swift xcode

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

Mainstoryboard

storyboard

storyboard

手机

enter image description here

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

当按下右下方的黄色按钮时移动。我的右键不是“ Bar Button Item”,而是一个按钮。原因是“ Bar Button”不是我想要的。

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

    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)

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

*******************编辑了两个************************** ***************** my board

移动主屏幕按钮

   @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)
                        }
                }
            }
        }
    }

*******************编辑的两个末端************************* ****************

2 个答案:

答案 0 :(得分:1)

您是否以编程方式展示ViewController?似乎没有显示导航栏。 如果在IBAction中,也许您必须提出。通过按钮创建它。将标识符设置为segue(在情节提要上),并使用以下命令调用它:

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

答案 1 :(得分:1)