Reputation: 901
This is my modified AppDelegate func
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let button = UIBarButtonItem(title: "Logs", style: .plain, target: self, action: #selector(logButtonTapped))
window?.rootViewController?.navigationItem.rightBarButtonItem = button
return true
}
I also added Navigation Controller before my VC as below
Even if the title is visible, the right navigation button is not visible. How can I make the navigation button visible so that I can click on it?
Plus, I get this error on console
UINavigationBar decoded as unlocked for UINavigationController, or navigationBar delegate set up incorrectly. Inconsistent configuration may cause problems.
Upvotes: -1
Views: 104
Reputation: 1
I am not sure if I understand what you are expecting very well. But I think you need to see the navBar button on the first page of your application. Isn't it?
So instead of doing this in the AppDelegate or SceneDelegate, you can add it directly to your viewController in the viewDidLoad()
method.
It will be something like this:
override func viewDidLoad() {
super.viewDidLoad()
let button = UIBarButtonItem(title: "Logs", style: .plain, target: self, action: #selector(self.logButtonTapped))
navigationItem.rightBarButtonItem = button
}
If this is not what you need, please provide more info about this
Upvotes: 0