Slide 1

Slide 1 text

# Type ʹDrag and Dropͷ࣮૷Λͯ͠Έͨ WWDC After Party 2017 @Ebisu 1

Slide 2

Slide 2 text

Profile Kazuya Ueoka Timers inc.ͷiOSΤϯδχΞ Twitter: @fromkk Github: fromkk Qiita: fromkk 2

Slide 3

Slide 3 text

WWDC 2017ʹߦͬͯདྷ·ͨ͠✈ ϒϩά͍͔ͭ͘ॻ͍ͨͷͰΑ͔ͬͨΒ؍ͯͶ! http://techblog.timers-inc.com/archive/category/wwdc2017 3

Slide 4

Slide 4 text

ܰ͘ৼΓฦΓ • iMac Pro/iPad Pro 10.5Πϯν/HomePod౳ͷ৽঎඼ • iMac/Macbook ProͷΞοϓάϨʔυ • CoreML/Vision/ARKit/VRKit౳ͷ৽ٕज़ • CoreNFC/Music Kit౳৽APIͷղ์ • iOS 11/tvOS 11/watchOS 4/macOS High Sierra • etc... 4

Slide 5

Slide 5 text

Drag and Dropؔ࿈ηογϣϯ • 203 Introducing Drag and Drop • 223 Drag and Drop with Collection and Table View • 227 Data Delivery with Drag and Drop 5

Slide 6

Slide 6 text

ԿނDrag and DropରԠͳͷ͔ • ❌ iMac Pro͸ख͕ग़ͤͳ͍ • ❌ HomePod͸དྷ೥Ҏ߱ʹͳΒͳ͍ͱ೔ຊͰൃച͠ͳ͍ • ⭕ iPad Pro͸લ͔Βཉ͔ͬͨ͠ • ⭕ αΠζมΘΒͣϕθϧ͕ࡉ͘ͳΔ͚ͩͱ͔࠷ߴ↗ • ⭕ ৽͍͠࢓૊Έͩ͠ࢼͯ͠Έ͍ͨ‼ 6

Slide 7

Slide 7 text

ʊਓਓਓਓਓਓਓਓਓਓਓਓਓਓʊ ʼɹiPad Pro 10.5Πϯνങ͓͏ʻ ʉY^Y^Y^Y^Y^Y^Y^Y^Y^Yʉ (Keynote؍ऴΘͬͨΒͦͷ··஫จ) 7

Slide 8

Slide 8 text

ಧ͍ͨ 8

Slide 9

Slide 9 text

iPad Proಧ͍ͨ೔ʹ΍ͬͨࣄ • iOS 11 betaͷΠϯετʔϧ Ҏ্ 9

Slide 10

Slide 10 text

Typeͱ͸ • iOSରԠͷγϯϓϧͰܰྔͳ MarkdownΤσΟλ • ؆୯ͳϓϨϏϡʔ/ࣗಈอଘ/ΩʔϘʔ υೖྗิॿ • 3Dλον/SpotlightରԠ • Qiita/Github issue/Gist΁ͷ౤ߘରԠ • Realm Mobile PlatformΛར༻ͨ͠ಉ ظػೳ Type 10

Slide 11

Slide 11 text

Dragػೳͷར༻Օॴ • MarkdownҰཡը໘ 11

Slide 12

Slide 12 text

DragͷओཁΫϥε౳ • UIDragInteraction • UIDragInteractionDelegate • UIDragItem(itemProvider: NSItemProvider) 12

Slide 13

Slide 13 text

Dragͷ࣮૷ํ๏ʢͦͷ1ʣ func addSupportDragInteractionIfNeeded() { if #available(iOS 11.0, *) { let dragInteraction = UIDragInteraction(delegate: self) self.addInteraction(dragInteraction) } } 13

Slide 14

Slide 14 text

Dragͷ࣮૷ํ๏ʢͦͷ2ʣ @available (iOS 11.0, *) extension IndexViewCell: UIDragInteractionDelegate { func dragInteraction(_ interaction: UIDragInteraction, itemsForBeginning session: UIDragSession) -> [UIDragItem] { let provider = NSItemProvider(object: self.article.markdown as NSString) let dragItem = UIDragItem(itemProvider: provider) return [dragItem] } } 14

Slide 15

Slide 15 text

Dropػೳͷར༻Օॴ • Markdownฤूը໘ 15

Slide 16

Slide 16 text

DropͷओཁΫϥε౳ • UIDropInteraction • UIDropInteractionDelegate • UIDropProposal 16

Slide 17

Slide 17 text

Dropͷ࣮૷ํ๏(ͦͷ1) func addSupportDropInteractionIfNeeded() { if #available(iOS 11.0, *) { let dropInteraction = UIDropInteraction(delegate: self) self.view.addInteraction(dropInteraction) } } 17

Slide 18

Slide 18 text

Dropͷ࣮૷ํ๏(ͦͷ2) @available(iOS 11.0, *) extension RegisterViewController: UIDropInteractionDelegate { func dropInteraction(_ interaction: UIDropInteraction, canHandle session: UIDropSession) -> Bool { return session.canLoadObjects(ofClasses: [UIImage.self]) } func dropInteraction(_ interaction: UIDropInteraction, sessionDidUpdate session: UIDropSession) -> UIDropProposal { return UIDropProposal(operation: .copy) } func dropInteraction(_ interaction: UIDropInteraction, performDrop session: UIDropSession) { session.loadObjects(ofClass: UIImage.self) { (items) in items.forEach({ (item) in guard let image: UIImage = item as? UIImage else { return } self.upload(image) }) } } } 18

Slide 19

Slide 19 text

Demo 19

Slide 20

Slide 20 text

·ͱΊ • DockͷଘࡏʹΑΓiPad͕ΑΓPCʹۙͮ͘ͷͰߋʹීٴ͕ݟ ࠐ·ΕΔ! • iPadରԠ΄΅ඞਢ͔⁉ • Drag and Drop͸࣮૷͢Δ͚ͩͳΒ͔ͳΓ؆୯# • ৭ΜͳΞϓϦͱը໘্ͰϑΝΠϧͷ΍ΓͱΓग़དྷΔͷָ͍͠ ↗ 20

Slide 21

Slide 21 text

ͪͳΈʹ • TypeͷSwift 4ରԠ͸೉ແ͘׬ྃ͠·ͨ͠! • iOS 11͕ग़Δ·ͰϦϦʔεग़དྷͳ͍ͷ͕଴ͪԕ͍͠Ͱ͢" 21

Slide 22

Slide 22 text

͝੩ௌ༗೉͏͍͟͝·ͨ͠! 22