[英]iOS: Why isn't this View Controller getting pushed onto the Navigation Controller's stack?
[英]viewDidAppear() called before view controller is pushed onto navigation stack
我的情节提要中有一个基本的导航设置:嵌入在UINavigationController
的香草UIViewController
。 在我的主要VC中,我有两个按钮,每个按钮都连接到UIViewController
子类: LabelledVC
。 在子类的viewDidAppear(_:)
方法中,将导航项的titleView
设置为自定义图像:
class LabelledVC: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let logoImage = UIImage(named: "apple")
let logo = UIImageView(image: logoImage)
logo.contentMode = .scaleAspectFit
logo.frame = CGRect(x: 0, y: 0, width: 32, height: 32)
navigationItem.titleView = logo
}
}
由于某种原因,在应用加载时( 在将其推送到导航堆栈之前)会调用LabelledVC
的viewDidAppear(_:)
方法,这对我来说没有任何意义。 您可以在此处找到该项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.