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
360
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
プロジェクト新規参入者のリードタイム短縮の観点から見る、品質の高いコードとアーキテクチャを保つメリット
d_endo
1
1k
生成 AI を活用した toitta 切片分類機能の裏側 / Inside toitta's AI-Based Factoid Clustering
pokutuna
0
560
Macとオーディオ再生 2024/11/02
yusukeito
0
140
現場で役立つモデリング 超入門
masuda220
PRO
12
2.9k
デプロイを任されたので、教わった通りにデプロイしたら障害になった件 ~俺のやらかしを越えてゆけ~
techouse
51
32k
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
330
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
0
150
/←このスケジュール表に立ち向かう フロントエンド開発戦略 / A front-end development strategy to tackle a single-slash schedule.
nrslib
1
590
2万ページのSSG運用における工夫と注意点 / Vue Fes Japan 2024
chinen
3
1.3k
Server Driven Compose With Firebase
skydoves
0
390
Nuxtベースの「WXT」でChrome拡張を作成する | Vue Fes 2024 ランチセッション
moshi1121
1
490
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
230
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
296
20k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Gamification - CAS2011
davidbonilla
80
5k
A Tale of Four Properties
chriscoyier
156
23k
Fashionably flexible responsive web design (full day workshop)
malarkey
404
65k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
GraphQLの誤解/rethinking-graphql
sonatard
66
9.9k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Bash Introduction
62gerente
608
210k
Fireside Chat
paigeccino
32
3k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
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 • ׂͱ؆୯ • ରԠ͢ΔσϦήʔτ؆୯ • λονͨ͠ॴʹରԠ͢ΔใΛఆ͢Δͷ͕େม