繁体   English   中英

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

[英]Why can't I see the navigation back button on the iOS?

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

主板

故事板

故事板

手机

在此处输入图片说明

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

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

************************编辑开始************************ ************ 故事

    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? 似乎没有显示导航栏。 如果在IBAction中,也许您必须提出。 通过按钮创建它。 将标识符设置为segue(在情节提要上),并使用以下命令进行调用:

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

我认为您不需要根据自己的情况编写任何代码。 这是Apple提供的快速入门示例,非常清楚。 https://developer.apple.com/library/archive/referencelibrary/GettingStarted/DevelopiOSAppsSwift/ImplementNavigation.html#//apple_ref/doc/uid/TP40015214-CH16-SW1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM