晚上我有一個網點問題。iOS Swift:無自定義ViewController的IBOutlets
viewController1做出幾個實例ViewController2,呈現他們與一個控制的PageControl頁面容器。
問題是,視圖控制器網點在ViewController2始終爲零。
可能是因爲ViewController2是通過代碼實例化的。
我該如何解決這個問題?
這裏我創建了不同的ViewController2
let page = OnboardPageViewController(onboard: onboard)
pages.append(page)
這裏是ViewController2
的初始化代碼//--------------------
//MARK: - Outlets
//--------------------
@IBOutlet var backgroundVideoView: BackgroundVideo!
@IBOutlet var backgroundUIImage: UIImageView!
@IBOutlet var titleLabel: UILabel!
@IBOutlet var descriptionLabel: UILabel!
//--------------------
//MARK: - Properties
//--------------------
let onboard: Onboard
//--------------------
//MARK: - View's Methods
//--------------------
override func viewDidLoad() {
super.viewDidLoad()
print("loaded: \(onboard.title)")
//FIXME: - need to find a way to link the outlets even if the controller is called via code
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
print("presenting: \(onboard.title)")
}
init(onboard: Onboard) {
self.onboard = onboard
super.init(nibName: nil, bundle: nil)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
請包括控制器實例代碼 – Alladinian
@Alladinian現在檢查它:) –