Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Getting started with 3D Touch
Search
sonson
September 27, 2016
Programming
0
650
Getting started with 3D Touch
How to implement "touch and peek" function in iOS9.
sonson
September 27, 2016
Tweet
Share
More Decks by sonson
See All by sonson
計算グラフのJITコンパイラをLLVM on C++で作ろう
sonsongithub
2
530
LLVMでHalideみたいな計算グラフ+JITを作りたい
sonsongithub
0
1.3k
LLVM Tutorial 02 - わいわいswiftc
sonsongithub
1
370
LLVM Tutorial - わいわいswiftc
sonsongithub
0
280
How to make and publish a Swift playground book for iPad
sonsongithub
5
19k
Swiftで実装するHTML特殊文字の高速処理
sonsongithub
3
7.6k
First step of 3D touch
sonsongithub
0
570
SSLって必要ですか〜Let's Encryptを試してみよう
sonsongithub
3
520
Other Decks in Programming
See All in Programming
gopls を改造したら開発生産性が高まった
satorunooshie
8
240
のびしろを広げる巻き込まれ力:偶然を活かすキャリアの作り方/oso2024
takahashiikki
1
400
現場で役立つモデリング 超入門
masuda220
PRO
12
2.9k
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
420
Golang と Erlang
taiyow
8
1.9k
Why Spring Matters to Jakarta EE - and Vice Versa
ivargrimstad
0
950
OpenTelemetryでRailsのパフォーマンス分析を始めてみよう(KoR2024)
ymtdzzz
4
1.5k
go.mod、DockerfileやCI設定に分散しがちなGoのバージョンをまとめて管理する / Go Connect #3
arthur1
10
2.3k
Outline View in SwiftUI
1024jp
1
100
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
240
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
130
2万ページのSSG運用における工夫と注意点 / Vue Fes Japan 2024
chinen
3
1.3k
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
32
2.4k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Six Lessons from altMBA
skipperchong
26
3.5k
How to Think Like a Performance Engineer
csswizardry
19
1.1k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
46
2.1k
Art, The Web, and Tiny UX
lynnandtonic
296
20k
Product Roadmaps are Hard
iamctodd
PRO
48
10k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Visualization
eitanlees
144
15k
A Modern Web Designer's Workflow
chriscoyier
692
190k
A better future with KSS
kneath
238
17k
Transcript
ZPVSOBNF"MMSJHIUTSFTFSWFE3FEJTUSJCVUJPOPSQVCMJDEJTQMBZOPUQFSNJUUFEXJUIPVUXSJUUFOQFSNJTTJPOGSPNZPVSOBNF *OUSPEVDFUPVDIBOEQFFL 1SPHSBNNJOH ू·ΕSwift͖ʂSwiftѪձ vol11 :VJDIJ:PTIJEB 3FTFBSDIFS %&/40*5-BCPSBUPSZ *OD (FUUJOHTUBSUFEXJUI%UPVDI
4FMGJOUSPEVDUJPO sonson • sonson_twit@Twitter • sonsongithub@github Portfolio • 2tch(̎ͪΌΜͶΔϒϥβ)ͳͲͳͲ ຊۀ
• ΫϧϚۀք • ը૾ೝࣝͱ͔ɼUIͱ͔৭ʑ͓ͬͯΓ·͢ ιʔεΛެ։ͯ͠Δͷ͋Γ·͢ IUUQHJUIVCDPNTPOTPOHJUIVC
SFEEJGU 0QFOTPVSDFQSPKFDU 1ԯਓҎ্ͷΞϝϦΧͷSNS API͋Γ Objective-CͷAPI Wrapper͋Γ • OAuth2ʹରԠͯ͠ͳ͍ • Swift͡Όͳ͍
Α͠ɼ͍ͬͪΐɼझຯʴษڧ͕ͯΒ࡞Δ͔ʂ MIT License
4XJGU GSPNUP ݁ • beta1͔Βॱʹશ෦ରԠͨ͠ɾɾɾͳͷͰۤ࿑͕ബΕ͍ͯΔͱ͍͏͔ҧ͍͕Θ͔Βͳ͍ ۤ࿑ͨ͠ͱ͜Ζ • SwiftͰ࡞ΒΕͨ֎෦ϥΠϒϥϦͷϝϯςφϯε • SwiftͰ࡞ΒΕͨ֎෦ϥΠϒϥϦͷϝϯςφϯε
• SwiftͰ࡞ΒΕͨ֎෦ϥΠϒϥϦͷϝϯςφϯε • ҙຯෆ໌ͳ༷มߋʢมͷܕͱ͔ʣ
5PVDIBOEQFFL *OUSPEVDF%UPVDI ༻ҙ • registerForPreviewing(with:sourceView:) • unregisterForPreviewing(withContext:) σϦήʔτ - UIViewControllerPreviewingDelegate
• previewingContext(_:viewControllerForLocation:) • previewingContext(_:commit:)
%UPVDI 1. registerForPreviewingͰ४උ͢Δ 2. Ϣʔβ͕ڧ͘ԡ͢ 3. previewingContext(_:viewControllerForLocation:)͕ݺΕΔ 4. ԡ͞ΕͨྖҬΛઃఆ͢Δ 5.
͜͜Ͱview controllerΛ࡞Γɼฦ͢ 6. ࠷ޙ·Ͱڧ͘ԡ͠ࠐΉ 7. previewingContext(_:commit:)͕ݺΕΔ 8. ͜͜Ͱ͖ͬ͞࡞ͬͨview controllerΛͲ͏͢Δ͔ܾΊΔ
QSFWJFXJOH$POUFYU @WJFX$POUSPMMFS'PS-PDBUJPO 1SFQBSFBWJFXDPOUSPMMFSGPSQFFLJOH ϝΠϯʹΔ͜ͱ • view controllerΛ࡞Δ • ԡ͞ΕͨॴͷใΛఆ͢Δ •
ॴΛcontextʹೖྗ͢Δ • view controllerͷαΠζΛܾఆ͢Δ
QSFWJFXJOH$POUFYU @WJFX$POUSPMMFS'PS-PDBUJPO $SFBUFWJFXDPOUSPMMFSBOEGFUDIDPOUFOUT func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint)
-> UIViewController? { // Create new view controller for peeking let controller = WebViewController(nibName: nil, bundle: nil) let locationInTextView = self.view.convert(location, to: textView) // get contents controller.url = getUrl(at: locationInTextView) return controller }
QSFWJFXJOH$POUFYU @DPNNJU )PXJTUIFWJFXDPOUSPMMFSTIPXO ϝΠϯʹΔ͜ͱ • ࠓද͍ࣔͯ͠Δview controllerΛͲ͏͢Δ͔ܾΊΔ UIViewControllerͷ͓࡞๏ͰΓ·͠ΐ͏ • modalʁ
• pushʁ • ಠࣗʁʢ͓͢͢Ί͠ͳ͍ʣ
QSFWJFXJOH$POUFYU @DPNNJU 1VTI1SFTFOUWJFXDPOUSPMMFS func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController)
{ // Modal let nav = UINavigationController(rootViewController: viewControllerToCommit) self.present(nav, animated: true, completion: nil) // Push navigationController?.pushViewController(viewControllerToCommit, animated: false) }
.FOV
)PXUPQSFQBSFNFOVJUFNT override var previewActionItems : [UIPreviewActionItem] { get { let
action1 = UIPreviewAction(title: “action1”, style: .default) { previewAction, viewController in print(title) } let action2 = UIPreviewAction(title: “delete”, style: .destructive) { previewAction, viewController in print(title) } return [action1, action2] } }
ۤ࿑͢Δͱ͜Ζʁ ॴͷ͋Δίϯςϯπͷऔಘ • CGRect • func contains(_ point: CGPoint) ->
Bool ͋ΔViewͷCGRectCGPointΛଞͷView͔Βݟͨͱ͖ɾɾɾɾ • UICoordinateSpaceϓτϩίϧΛ͏ • func convert(CGPoint, to: UICoordinateSpace) • func convert(CGPoint, from: UICoordinateSpace) • func convert(CGRect, to: UICoordinateSpace) • func convert(CGRect, from: UICoordinateSpace)
αϯϓϧ ιʔείʔυ • https://github.com/sonsongithub/UZTextView/tree/develop • Sample3DTouch project WWDC2016 • https://developer.apple.com/videos/play/wwdc2016/228/
·ͱΊ Swift3 • SwiftͰ࡞ΒΕͨ֎෦ϥΠϒϥϦͷϝϯςφϯε • SwiftͰ࡞ΒΕͨ֎෦ϥΠϒϥϦͷϝϯςφϯε • SwiftͰ࡞ΒΕͨ֎෦ϥΠϒϥϦͷϝϯςφϯε • SwiftͰ࡞ΒΕͨ֎෦ϥΠϒϥϦͷϝϯςφϯε
3D touch - Touch & Peek • ׂͱ؆୯ • ରԠ͢ΔσϦήʔτ؆୯ • λονͨ͠ॴʹରԠ͢ΔใΛఆ͢Δͷ͕େม