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
680
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
550
LLVMでHalideみたいな計算グラフ+JITを作りたい
sonsongithub
0
1.3k
LLVM Tutorial 02 - わいわいswiftc
sonsongithub
1
370
LLVM Tutorial - わいわいswiftc
sonsongithub
0
290
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
590
SSLって必要ですか〜Let's Encryptを試してみよう
sonsongithub
3
520
Other Decks in Programming
See All in Programming
今からはじめるAndroidアプリ開発 2024 / DevFest 2024
star_zero
0
1k
Haze - Real time background blurring
chrisbanes
1
510
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
1
360
103 Early Hints
sugi_0000
1
220
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
130
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
200
テスト自動化失敗から再挑戦しチームにオーナーシップを委譲した話/STAC2024 macho
ma_cho29
1
1.3k
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
130
第5回日本眼科AI学会総会_AIコンテスト_3位解法
neilsaw
0
170
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1k
たのしいparse.y
ydah
3
120
Featured
See All Featured
XXLCSS - How to scale CSS and keep your sanity
sugarenia
247
1.3M
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Become a Pro
speakerdeck
PRO
26
5k
Building Applications with DynamoDB
mza
91
6.1k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
It's Worth the Effort
3n
183
28k
Designing for humans not robots
tammielis
250
25k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
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 • ׂͱ؆୯ • ରԠ͢ΔσϦήʔτ؆୯ • λονͨ͠ॴʹରԠ͢ΔใΛఆ͢Δͷ͕େม