iosbegindevel
iosbegindevel

Reputation: 327

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

I am a beginner in iOS development. I have a problem when I move the screen. I clicked the button on the story board, then drag it with the right mouse, and then clicked on the view controller that I wanted to move. However, the navigation back button is not visible when the button is pressed. What's the reason?

Main.storyboard

storyboard

storyboard

Cell phone

enter image description here

Move when the lower right yellow button is pressed.

Move when the lower right yellow button is pressed. My right button is not 'Bar Button Item' but just a button. The reason is that 'Bar Button' is not what I want.

************************ Edited Start ************************************ 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" {

        }
    }

Error is Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ffee5677ff8)

************************ Edited end ************************************

*******************Edited Two ******************************************* my board

Move Main Screen Button

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

*******************Edited Two end *****************************************

Upvotes: 0

Views: 662

Answers (2)

Ansersion
Ansersion

Reputation: 62

I think that you don't need any code for your situation. Here is a Quick-Start example from Apple which is very clear. https://developer.apple.com/library/archive/referencelibrary/GettingStarted/DevelopiOSAppsSwift/ImplementNavigation.html#//apple_ref/doc/uid/TP40015214-CH16-SW1

Upvotes: 1

DungeonDev
DungeonDev

Reputation: 1226

Are you presenting the ViewController programmatically? It seems that the navigation bar is not shown. Maybe you have to present if in a IBAction. Create it connecting a button. Set the identifier to the segue (on the Storyboard) and call it with:

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

Upvotes: 1

Related Questions