Fix crash when long-presing add attachment button
This commit is contained in:
parent
e3cc0df283
commit
478c7b7a23
|
@ -266,6 +266,8 @@ class ComposeAttachmentsViewController: UITableViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
|
override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
|
||||||
|
guard indexPath.section == 0 else { return nil }
|
||||||
|
|
||||||
let attachment = attachments[indexPath.row]
|
let attachment = attachments[indexPath.row]
|
||||||
// cast to NSIndexPath because identifier needs to conform to NSCopying
|
// cast to NSIndexPath because identifier needs to conform to NSCopying
|
||||||
return UIContextMenuConfiguration(identifier: indexPath as NSIndexPath, previewProvider: { () -> UIViewController? in
|
return UIContextMenuConfiguration(identifier: indexPath as NSIndexPath, previewProvider: { () -> UIViewController? in
|
||||||
|
@ -300,12 +302,15 @@ class ComposeAttachmentsViewController: UITableViewController {
|
||||||
let sheetContainer = AssetPickerSheetContainerViewController()
|
let sheetContainer = AssetPickerSheetContainerViewController()
|
||||||
sheetContainer.assetPicker.assetPickerDelegate = self
|
sheetContainer.assetPicker.assetPickerDelegate = self
|
||||||
present(sheetContainer, animated: true)
|
present(sheetContainer, animated: true)
|
||||||
|
//setOverrideTraitCollection(UITraitCollection(userInterfaceLevel: .elevated), forChild: sheetContainer)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ComposeAttachmentsViewController: UITableViewDragDelegate {
|
extension ComposeAttachmentsViewController: UITableViewDragDelegate {
|
||||||
func tableView(_ tableView: UITableView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
|
func tableView(_ tableView: UITableView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
|
||||||
|
guard indexPath.section == 0 else { return [] }
|
||||||
|
|
||||||
let attachment = attachments[indexPath.row]
|
let attachment = attachments[indexPath.row]
|
||||||
let provider = NSItemProvider(object: attachment)
|
let provider = NSItemProvider(object: attachment)
|
||||||
let dragItem = UIDragItem(itemProvider: provider)
|
let dragItem = UIDragItem(itemProvider: provider)
|
||||||
|
@ -314,6 +319,8 @@ extension ComposeAttachmentsViewController: UITableViewDragDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
func tableView(_ tableView: UITableView, itemsForAddingTo session: UIDragSession, at indexPath: IndexPath, point: CGPoint) -> [UIDragItem] {
|
func tableView(_ tableView: UITableView, itemsForAddingTo session: UIDragSession, at indexPath: IndexPath, point: CGPoint) -> [UIDragItem] {
|
||||||
|
guard indexPath.section == 0 else { return [] }
|
||||||
|
|
||||||
let attachment = attachments[indexPath.row]
|
let attachment = attachments[indexPath.row]
|
||||||
let provider = NSItemProvider(object: attachment)
|
let provider = NSItemProvider(object: attachment)
|
||||||
let dragItem = UIDragItem(itemProvider: provider)
|
let dragItem = UIDragItem(itemProvider: provider)
|
||||||
|
@ -322,6 +329,8 @@ extension ComposeAttachmentsViewController: UITableViewDragDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
func tableView(_ tableView: UITableView, dragPreviewParametersForRowAt indexPath: IndexPath) -> UIDragPreviewParameters? {
|
func tableView(_ tableView: UITableView, dragPreviewParametersForRowAt indexPath: IndexPath) -> UIDragPreviewParameters? {
|
||||||
|
guard indexPath.section == 0 else { return nil }
|
||||||
|
|
||||||
let cell = tableView.cellForRow(at: indexPath) as! ComposeAttachmentTableViewCell
|
let cell = tableView.cellForRow(at: indexPath) as! ComposeAttachmentTableViewCell
|
||||||
let rect = cell.convert(cell.assetImageView.bounds, from: cell.assetImageView)
|
let rect = cell.convert(cell.assetImageView.bounds, from: cell.assetImageView)
|
||||||
let path = UIBezierPath(roundedRect: rect, cornerRadius: cell.assetImageView.layer.cornerRadius)
|
let path = UIBezierPath(roundedRect: rect, cornerRadius: cell.assetImageView.layer.cornerRadius)
|
||||||
|
|
Loading…
Reference in New Issue