kkbox wwdc17 uikit drag and drop - mario

22
Drag and Drop in iOS 11 Mario Tung KKTV

Upload: liyao-chen

Post on 22-Jan-2018

2.065 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: KKBOX WWDC17  UIKit Drag and Drop - Mario

Drag and Drop in iOS 11

Mario TungKKTV

Page 2: KKBOX WWDC17  UIKit Drag and Drop - Mario

Summary- Goals for drag and drop- Different phases of a drag session- Essential Functions- Drag delegates- Drop delegates- Next step

Page 3: KKBOX WWDC17  UIKit Drag and Drop - Mario

What is drag and drop?A way to move data around

Page 4: KKBOX WWDC17  UIKit Drag and Drop - Mario

Goals for Drag and DropResponsive

- On demand / Async data transfer

Secure

- Source app can choose what data to transfer / who to transfer to- Data is only visible to destination

Great multi touch experience

- Deep integration with iOS apps- Multiple types of touch/gestures can be used

Page 5: KKBOX WWDC17  UIKit Drag and Drop - Mario

Demo

Page 6: KKBOX WWDC17  UIKit Drag and Drop - Mario

Phases of a drag session

Data transfer time depends on file size

Page 7: KKBOX WWDC17  UIKit Drag and Drop - Mario

Drag begins: get data items

- Use UIDragItems for transferring data- NSItemProvider only allows objects (not string structs)

Page 8: KKBOX WWDC17  UIKit Drag and Drop - Mario

Get drop proposal during session update

- Called when touch point has moved in view / additional items are added- Return what to do when user drops item now- 4 types of UIDropOperations (Cancel / Copy / Move / Forbidden)- Move operation is only allowed within the same app

Page 9: KKBOX WWDC17  UIKit Drag and Drop - Mario

Perform the drop

- Perform data transfer of objects

Page 10: KKBOX WWDC17  UIKit Drag and Drop - Mario

Customizing Drag and Drop- Use the drag interaction delegate to find out when views are lifted / being

dragged around

- Use drop interaction delegate to find out when an item has entered view / dropped into view

Page 11: KKBOX WWDC17  UIKit Drag and Drop - Mario

Drag interaction delegate - Lift

- View to be shown when dragging

Page 12: KKBOX WWDC17  UIKit Drag and Drop - Mario

Drag interaction delegate - Session begins and moves

Page 13: KKBOX WWDC17  UIKit Drag and Drop - Mario

Drag interaction delegate - Adding more items

- Add additional items to drag session- Update preview view accordingly

Page 14: KKBOX WWDC17  UIKit Drag and Drop - Mario

Drag interaction delegate - End session

- Session is going to end with one of the four types of UIDropOperation

Page 15: KKBOX WWDC17  UIKit Drag and Drop - Mario

Drag interaction delegate - End session (Cancel)

Page 16: KKBOX WWDC17  UIKit Drag and Drop - Mario

Drag interaction delegate - End session (Copy/Move)

Page 17: KKBOX WWDC17  UIKit Drag and Drop - Mario

Drop interaction delegates

Page 18: KKBOX WWDC17  UIKit Drag and Drop - Mario

Drop interaction delegate - Session enters view

- Can be used to filter out types of data that are accepted

Page 19: KKBOX WWDC17  UIKit Drag and Drop - Mario

Drop interaction delegate - Session enters/exits view

- Enter/update/exit can happen multiple times - delegates will keep getting called

Page 20: KKBOX WWDC17  UIKit Drag and Drop - Mario

Drop interaction delegate - Drop animations

- Execute any further UI changes to the UITargetedDragPreview from previewForLifting

Page 21: KKBOX WWDC17  UIKit Drag and Drop - Mario

Next step - exploring more

Page 22: KKBOX WWDC17  UIKit Drag and Drop - Mario