[英]registerForPreviewing in a tableview cell, iOS, Swift
I'm trying to add this to a table view cell but because it is awake from nib and not view did load it won't allow it. 我试图将其添加到表视图单元格中,但是因为它已从笔尖中唤醒,并且未加载视图,所以不允许这样做。
if traitCollection.forceTouchCapability == .available
{
registerForPreviewing(with: self as! UIViewControllerPreviewingDelegate, sourceView: collectionView)
}
else
{
print("3D Touch Not Available")
}
Remember that is a delegate, registerForPreviewing initialize the delegate's instance. 请记住,这是一个委托,registerForPreviewing初始化委托的实例。 You can do it in the dequeue:
您可以在出队中做到这一点:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: BBVAIntranet_Somos_Comedores_Menu_Dia_CollectionViewCell.identifier,
for: indexPath) as? BBVAIntranet_Somos_Comedores_Menu_Dia_CollectionViewCell {
print("item: \(indexPath.item)")
self.refrescar_menuDia_delegate = cell
if traitCollection.forceTouchCapability == .available {
registerForPreviewing(with: cell, sourceView: cell.tableView)
}
self.refrescar_menuDia_delegate?.refrescar_menu_dia_collectioncell_delegate(menu: self.menus[indexPath.item])
return cell
}
return UICollectionViewCell()
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.