I have successfully chain linked delegate methods from CollectionViewController
-> MenuTableViewController
-> ListViewController
. In ListViewController
extension I call changeTitleView()
but it is not working. The data, however is successfully passed because print(title)
correctly prints passed information. changeTitle()
executes properly if called from within ListViewController
class ListViewController {
var navigationTitle: String?
@objc func changeTitle(title: String) {
let titleLabel = UILabel()
let attributes: NSDictionary = [
NSAttributedStringKey.font:UIFont(name: "HelveticaNeue", size: 20)!,
NSAttributedStringKey.foregroundColor: UIColor(red: 0.1137, green: 0.1137, blue: 0.149, alpha: 0.8) /* #1d1d26 */,
NSAttributedStringKey.kern:CGFloat(2.0)
]
let attributedTitle = NSAttributedString(string:
title.uppercased(), attributes: attributes as? [NSAttributedStringKey : AnyObject])
titleLabel.attributedText = attributedTitle
titleLabel.sizeToFit()
self.navigationItem.titleView = titleLabel
}
}
extension ListViewController: HandleTitleView {
@objc func changeTitleView(title: String) {
print(title)
self.navigationTitle = title
changeTitle(title: navigationTitle!)
}
Additional information:
1) I am passing information through SWRevealController so not all data is within the same navigation stack. ListViewController
is on top of MenuTableViewController
and CollectionViewController
is instantiated from MenuTableViewController
and then dismissed
2) I created a button in ListViewController
that calls changeTitle()
and it successfully changes the navigationItem.titleView
so I know the method works.
Thanks in advance
and you can download the code from this link
Link
Did you try like below