Create new windows on iPadOS by dragging
This commit is contained in:
parent
ffbbecd953
commit
67b3b95f53
1 changed files with 7 additions and 4 deletions
|
@ -279,12 +279,15 @@ class PostCollectionView: UICollectionView, UICollectionViewDataSource, UICollec
|
|||
|
||||
func collectionView(_ collectionView: UICollectionView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
|
||||
let model = posts[indexPath.item]
|
||||
|
||||
let activity = NSUserActivity(activityType: "post")
|
||||
activity.userInfo = ["name": model.value(forKey: "name")!]
|
||||
activity.isEligibleForHandoff = true
|
||||
|
||||
let itemProvider = NSItemProvider(object: (cellForItem(at: indexPath) as! PostViewCell).imageView.image!)
|
||||
itemProvider.suggestedName = model.value(forKey: "name") as? String
|
||||
itemProvider.registerObject(activity, visibility: .all)
|
||||
|
||||
let dragItem = UIDragItem(itemProvider: itemProvider)
|
||||
dragItem.localObject = model //We can set the localObject property for convenience
|
||||
|
||||
return [dragItem]
|
||||
return [UIDragItem(itemProvider: itemProvider)]
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue