[英]IB Outlet for NativeAd is nil in a tableview cell
let nativeAdCell = tableView.dequeueReusableCell(
withIdentifier: "Ads", for: indexPath) as! NativeAds
然后
(nativeAdCell.HeadlineView).text = nativeAd.headline
(nativeAdCell.PriceView).text = nativeAd.price
運行時,出現錯誤,說明 Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value。 這意味着視圖為零
編輯 1
tableview.register(NativeAds.self, forCellReuseIdentifier: "Ads")
let nativeAdCell = tableView.dequeueReusableCell(
withIdentifier: "Ads", for: indexPath) as! NativeAds
我是如何注冊的,我為此使用了 Xib 文件
按照以下代碼在表格視圖中注冊 XIB 文件:
tableView.register(UINib(nibName: "yourNibFileName", bundle: nil), forCellReuseIdentifier: "yourIdentier")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.