iOS 应用功能扩展指南
一、附件删除功能实现
在 iOS 应用中,实现附件删除功能需要进行如下操作:
1. 删除附件代码 :在特定的逻辑中添加以下代码来删除附件并结束编辑模式。
self.attachmentsCollectionView?
.deleteItems(at: [indexPath])
self.endEditMode()
} catch let error as NSError {
NSLog("Failed to delete attachment: \(error)")
}
- 设置单元格委托 :在
collectionView(_, cellForItemAt indexPath:)方法中添加代码,将单元格的委托设置为self,并添加长按手势。
// Add a long-press gesture to it, if it doesn't
// already have it
let longPressGesture = UILongPressGestureRecognizer(target: self,
action: #selector(DocumentViewController.beginEditMode))
attachmentCell.gestureRecognizers
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



