Setting title of UINavigationbar not working

前端 未结 2 1165
孤独总比滥情好
孤独总比滥情好 2021-01-26 01:43

I\'ve looked through a few online tutorials, but nothing is working.

That\'s the code of my viewController:

import UIKit

class ViewController: UINavigat         


        
2条回答
  •  生来不讨喜
    2021-01-26 02:21

    First of all in your storyboard select your view controller and then

    Editor -> Embed In -> Navigation Controller

    then in your ViewController class add

    self.title = "AAA"
    

    in your viewDidLoad method and your code will look like:

    class ViewController: UIViewController {
    
        override func viewDidLoad() {
            super.viewDidLoad()
            self.title = "AAA"
        }
    }
    

    You need to replace UINavigationController with UIViewController

提交回复
热议问题