Reputation: 1
When navigating away from the view controller and subsequently returning, the custom titleView fails to reappear and not even visible in the view hierarchy, indicating a possible issue with the view's lifecycle management or navigation stack handling that prevents the titleView from being properly reinitialized or displayed.
func setTitleView() {
let titleView = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 44))
titleView.clipsToBounds = true
titleView.backgroundColor = .orange
self.navigationItem.titleView?.isHidden = false
self.titleLabel.textAlignment = .center
self.titleLabel.font = UIFont.systemFont(forTextStyle: .title)
self.titleLabel.backgroundColor = .blue
self.titleLabel.textColor = UIColor.primaryBlackColor //UIColor.white
titleView.addSubview(self.titleLabel)
self.navigationItem.titleView = titleView
self.titleLabel.text = "adsvhjasjhdfgka"
}
I'm calling this function in viewDidAppear().your text
Upvotes: 0
Views: 12