The built-in navigation bar disappears on iOS 7 (small screen size), but not iOS 9 (larger screen) after segue

I have a show segue, called showPage, from the view controller to the table view controller, and cause performSegueWithIdentifier()it to appear after clicking the "OK" button on the button in the message:

@IBAction func enterManuallyTap(sender: AnyObject) {
    var code : String!
    if #available(iOS 8.0, *) {
        let alert = UIAlertController(title: "Enter code", message: "Please enter code", preferredStyle: UIAlertControllerStyle.Alert)
        alert.addTextFieldWithConfigurationHandler({ (input:UITextField) in
            input.placeholder = "your code"
        });
        alert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil))
        alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: { (_) in
            barcode = alert.textFields!.first?.text
            self.performSegueWithIdentifier("showPage", sender: self)
        }))
        presentViewController(alert, animated: true, completion: nil)
    } else {
        let alert = UIAlertView(title: "Enter code", message: "Please enter code", delegate: self, cancelButtonTitle: "Cancel", otherButtonTitles: "OK")
        alert.alertViewStyle = UIAlertViewStyle.PlainTextInput
        alert.show()
    }
}

func alertView(alertView: UIAlertView, clickedButtonAtIndex buttonIndex: Int) {
    if buttonIndex == 1 {
        var code : String!
        code = alertView.textFieldAtIndex(0)?.text
        self.performSegueWithIdentifier("showPage", sender: self)
    }
}

All this works fine on my iOS 9 device, but when I try to use it on an iOS 7 device, the navigation bar disappears, so I can’t see the name or press “back”. Therefore, the table view starts at the very top of the screen and goes to the status bar.

I tried changing the top bar from inferredto Translucent Navigation Barand set nagivationBarHiddento false

    self.navigationController?.navigationBarHidden = false

but it still does not appear on iOS 7.

print(self.navigationController) viewDidAppear() tableviewcontroller, iOS 7 nil, iOS 9 : Optional(<UINavigationController: 0x12504e600>)! ? , , , , , , .

, iOS 7 ( )?

- , iOS 9, , ? ( iPhone 6S), iOS 7 - iPhone 4, . , , ? , , .

( ):

enter image description here

- , "" .

+4
1

, showSegue (showPage)

Apple

(Push)

, showViewController: : . , . . , .

, viewController UINavigationController Storyboard. navigationController initialViewController, viewController - initialViewController. viewController modally. , navigationBar viewController. , .

. :
'' segue Xcode 6 viewcontroller iOS 7

+2

Source: https://habr.com/ru/post/1665907/


All Articles