I have a UINavigationItem
i am trying to show a UIBarButtonItem
.
Now the problem is i added them correctly, they're functional and working 100%.
but they're not showing on the UINavigationBar
.
Now for the flow I am doing the following.
1- I am hiding the back button, like this
self.navigationItem.setHidesBackButton(isBackHidden, animated: false)
2- I am adding those 2 buttons using a function dynamically at run time, when a user tap on a UIButton
.
let rightBarItem = UIBarButtonItem(title: "Button.Done".localized, style: .plain, target: self, action: #selector(self.saveButtonTapped))
navigationItem.rightBarButtonItem = rightBarItem
let leftBarItem = UIBarButtonItem(title: "Button.Cancel".localized, style: .plain, target: self, action: #selector(self.cancelButtonTapped))
navigationItem.rightBarButtonItem?.tintColor = .red // still nothing
navigationItem.leftBarButtonItem = leftBarItem
3- I have tried to use those functions and still the same result
self.navigationItem.setLeftBarButton(UIBarButtonItem?, animated: Bool)
self.navigationItem.setRightBarButton(UIBarButtonItem?, animated: Bool)
Summary :
I have tried to change the tintColor
as they're functionally working i thought it was a color problem.
I have tried to use them inside DispatchQueue.main.async {}
thinking it might be a thread problem since it dynamic.
I have debugged and check for the items in the UINavigationItem
and they're exist.
What is going on mainly:
The buttons are not shown but they are working just fine when tapped on their places on the UINavigationItem
.