У меня есть UITableView с ячейками, содержащими настроенные слои , такие как тени, рисование линий и угловых радиусов . Я сделал дизайн через раскадровку, используя Autolayout в IPhone SE размер представления.
Проблема заключается в том, что при первой инициализации UITableView он выглядит так (что не должно быть):
Однако, когда прокручивая вниз, он показывает, что и должно быть, например:
Я сделал так много вещей, чтобы обновить его, например:
cell?.imageView.invalidateIntrinsicContentSize()
cell?.imageView.setNeedsUpdateConstraints()
cell?.imageView.setNeedsLayout()
cell?.imageView.layoutIfNeeded()
cell?.imageView.setNeedsDisplay()
cell?.imageView.translatesAutoresizingMaskIntoConstraints = false
, но это не работает.
Итак, есть ли идеи, чтобы сделать его вторым изображением после загрузки первого дисплея?
- Обновлено -
Здесь cellForRow
для соответствующего tableView:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell: GProjectsFTContentTVCell = tableView.dequeueReusableCell(withIdentifier: "GProjFTContentHeaderCellID") as! GProjectsFTContentTVCell
cell.performPopulateData(data: self.contentInfo![indexPath.row])
tableView.reloadRows(at: [indexPath], with: UITableView.RowAnimation.automatic)
return cell
}
и его класс ячейки:
func performPopulateData(data: APIJSON.ProjectList)
{
let urlFriendlyFileName: String? = data.cover?.replacingOccurrences(of: " ", with: "%20")
self.vwGPFTCTVCBannerPanel.layer.cornerRadius = 20
self.vwGPFTCTVCBannerPanel.dropShadow()
self.ivGPFTCTVCBannerImage.roundCorners(corners: [.topLeft, .topRight], radius: 20.0)
AF.request(urlFriendlyFileName ?? "").responseImage(completionHandler: { response in
if let image = response.value {
self.ivGPFTCTVCBannerImage.image = image
}
})
self.lblGPFTCTVCTitle.text = data.title
self.lblGPFTCTVCTitle.font = FontPredefine.SFProSemiBold(withSize: 16.0)
self.lblGPFTCTVCTitle.textColor = ColorPredefine.greenTextColor
self.lblGPFTCTVCSubTitle.text = data.subtitle
self.lblGPFTCTVCSubTitle.font = FontPredefine.SFProRegular(withSize: 12.0)
}
Для макета я сделал следующее: как это: