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
iPhoneX対応とScrollViewのcontentInset
Search
kNagadou
April 03, 2018
Programming
1
680
iPhoneX対応とScrollViewのcontentInset
ROPPONGI.swift #2 の発表用スライドです。
kNagadou
April 03, 2018
Tweet
Share
More Decks by kNagadou
See All by kNagadou
勇気を出して、Appleにバグレポートを出してみませんか?
knagadou
0
1.1k
Musicアプリのトランジションを再現する
knagadou
3
2.4k
テスト実行時に 不要な初期化コードを実行しないようにする
knagadou
4
1.4k
Other Decks in Programming
See All in Programming
暇に任せてProxmoxコンソール 作ってみました
karugamo
1
640
Testing Assembly: Code or Low Code - Navigating the Test Automation Options
maaretp
0
110
TypeScript でバックもやるって実際どう? 実運用で困ったこと3選
yuichiro_serita
17
7.7k
HTTP compression in PHP and Symfony apps
dunglas
2
1.6k
103 Early Hints
sugi_0000
1
180
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
280
Thoughts and experiences on Rust and TypeScript
unvalley
2
220
Amazon Aurora Serverless v2のアプデと、Amazon Aurora PostgreSQL Limitless DatabaseのGAについて
satoshi256kbyte
0
120
testcontainers のススメ
sgash708
1
110
nekko cloudにおけるProxmox VE利用事例
irumaru
3
320
第5回日本眼科AI学会総会_AIコンテスト_3位解法
neilsaw
0
160
14 Years of iOS: Lessons and Key Points
seyfoyun
1
750
Featured
See All Featured
Gamification - CAS2011
davidbonilla
80
5.1k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
How to train your dragon (web standard)
notwaldorf
88
5.7k
How GitHub (no longer) Works
holman
311
140k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Making Projects Easy
brettharned
116
5.9k
Optimising Largest Contentful Paint
csswizardry
33
3k
Site-Speed That Sticks
csswizardry
1
180
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.1k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
1
160
Transcript
J1IPOF9ରԠͱ 6*4DSPMM7JFXͷDPOUFOU*OTFU ,":"$ٕज़෦ ,B[VNBTB/"("%0 30110/(*TXJGU
w ,B[VNBTB/"("%0 w ,":"$d w 5XJUUFS!L[NTOHE w ʢʣ/1$+ϑΟδʔΫϊʔϏε DNҎԼΫϥεग़༧ఆ w
IUUQTOQDKKQDPOUFTUOFXHFOFSBUJPODMBTTJD 1SPpMF
2ݮྔதʹ৯ͯྑ͍ͷʁ ͓ण࢘ ύελྉཧ ͓ʹ͗Γ εΠʔπ ࠓ͔Βग़དྷΔݮྔΫΠζ
"શ෦0, ʢ˞ઁऔ͢ΔλΠϛϯάɺຊؾʹΑΔʣ ࠓ͔Βग़དྷΔݮྔΫΠζ
2ͲͷτϨʔχϯά͕ےΛେ͖͘Ͱ͖Δʁ ϕϯνϓϨεLHYճ ϕϯνϓϨεLHYճ ࠓ͔Βग़དྷΔےංେΫΠζ
"ͲͪΒےංେ͢Δ ʢ˞ݶք·Ͱ͍ࠐΉ͜ͱ͕લఏʣ ࠓ͔Βग़དྷΔےංେΫΠζ
ϓϥίϨ8FEEJOH IUUQTQMBDPMFXFEEJOH %SFTTZCZϓϥίϨ IUUQTESFTTZQMBDPMFXFEEJOH ϓϥίϨ
ˎ8FC൛ IUUQTXFCMPCJDP ˎJ5VOFT"QQ4UPSF IUUQTJUVOFTBQQMFDPNKQBQQMPCJϩϏʔJE NU ˎ"OESPJE IUUQTQMBZHPPHMFDPNTUPSFBQQTEFUBJMT JEDPNLBZBDOBLBNBQIMKB
ήʔϜ߈ུνϟοτ4/4 -PCJ
6QEBUFGPSJ1IPOF9
#VJMEXJUIJ044%, 9DPEFY
J1IPOF9ͷσΟεϓϨΠରԠ 4BGF"SFBରԠ ˠ6*4DSPMM7JFXͷදࣔྖҬ͕͓͔͍͠ɻௐ্͕ख͘Ͱ͖ͳ͍ɻ 6*4DSPMM7JFXͷ"VUP-BZPVUͱDPOUFOU*OTFUʹ͍͓ͭͯ͞Β͍ͯ͠ΈΔɻ
6*4DSPMM7JFX 6*5BCMF7JFX ͷ"VUP-BZPVUͰࠔΔ࣌ 6*/BWJHBUJPO#BS 6*4FBSDI#BS 6*5BCMF7JFX
DPOUFOU*OTFUͱ 6*4DSPMM7JFXͷGSBNF DPOUFOU*OTFUUPQ
DPOUFOU*OTFUͱ 6*4DSPMM7JFXͷGSBNF DPOUFOU*OTFUUPQ 6*4DSPMM7JFXίϯςϯπपลʹ ઃఆͰ͖Δ༨നͷ͜ͱ
6*4DSPMM7JFX 6*5BCMF7JFX ͷ"VUP-BZPVUͰࠔΔ࣌
6*4DSPMM7JFX 6*5BCMF7JFX ͷ"VUP-BZPVUͰࠔΔ࣌ Ṗͷεϖʔε
6*4DSPMM7JFX 6*5BCMF7JFX ͷ"VUP-BZPVUͰࠔΔ࣌ ͜͜ಉ͡Α͏ʹݟ͑Δ͕ɺ 6*5BCMF7JFX͕ը໘͍ͬͺ͍ʹ දࣔ͞Ε͍ͯͳ͍͜ͱ͕͔Δ
6*4DSPMM7JFX 6*5BCMF7JFX ͷ"VUP-BZPVUͰࠔΔ࣌ 6*4FBSDI#BSͷΈ্ʹҠಈ ͯ͠͠·͍ɺṖͷεϖʔε͕ൃੜ
DPOTUBOU 6*/BWJHBUJPO#BS 6*4FBSDI#BSͷߴ͞ Ͱ 6*5BCMF7JFXͷUPQʹ੍Λ͔͚͍ͯΔɻ ˠ6*4FBSDI#BSͱ6*5BCMF7JFXͷίϯςϯπͷؒʹ
ෆࣗવͳ伱͕ؒੜ·Εͯ͠·͏ɻ ˠ6*4FBSDI#BSͷڍಈɺ6*5BCMF7JFX͕ ը໘͍ͬͺ͍ʹදࣔ͞Ε͍ͯΔ͜ͱΛظ͍ͯ͠Δɻ 6*4DSPMM7JFX 6*5BCMF7JFX ͷ"VUP-BZPVUͰࠔΔ࣌
Ξϯνύλʔϯ ɾϔομʔʢϑολʔʣͳͲͷߴ͞ʹ߹Θͤͯɺ6*4DSPMM7JFXʹ"VUP -BZPVUΛ͔͚ͯ͠·͏ɻ ɾ$IJME7JFX$POUSPMMFS͔Β1BSFOU7JFX$POUSPMMFSͷ7JFXϑϨʔϜ Λࢀরͯ͠ɺ6*4DSPMM7JFXʹ"VUP-BZPVUΛ͔͚ͯ͠·͏ɻ
w ඪ४ͷ6* 6*4FBSDI#BSͳͲ Ճͨ࣌͠ʹɺෆࣗવͳ6*දࣔʹͳΔɻ w ϔομʔϑολʔͳͲʹ#MVSޮՌΛ͚͍ͨ࣌ʹࠔΔɻ w 1BSFOU7JFX$POUSPMMFSͱ$IJME7JFX$POUSPMMFSͷґଘੑ͕ߴ·Δʢϝϯ ςφϯε͠ਏ͍ʣɻ
ࠔΔ͜ͱ·ͱΊ
"QQMFͷΨΠυϥΠϯʹԊ͏Α͏ʹ 6*4DSPMM7JFXΛ࣮͢Δ IUUQTEFWFMPQFSBQQMFDPNKQEPDVNFOUBUJPO6*4DSPMM7JFX@QHQEG
6*4DSPMM7JFXը໘͍ͬͺ͍ʹදࣔ͢Δ self.tableView.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ self.tableView.topAnchor.constraint(equalTo: self.view.topAnchor), self.tableView.bottomAnchor.constraint(equalTo:
self.view.bottomAnchor), self.tableView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor), self.tableView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor) ]) ˠϔομʔϑολʔͷߴ͞ʹ߹Θͤͯ6*4DSPMM7JFX ͷαΠζΛௐͨ͠Γ͠ͳ͍Α͏ʹ͢Δɻ
σϑΥϧτͰBEKVTUFE$POUFOU*OTFU͕༗ޮʹͳ͍ͬͯΔͨΊɺಛʹ DPOUFOU*OTFUͷௐෆཁɻ ˠBEKVTUFE$POUFOU*OTFUʹΑΓɺDPOUFOU*OTFU͕4BGF"SFBʹ߹ Θͤͯࣗಈௐ͞ΕΔɻ DPOUFOU*OTFUͷௐ J04
DPOUFOU*OTFUͷௐ J04 1BSFOU7JFX$POUSPMMFSͰཧ͍ͯ͠Δ7JFXͷϑϨʔϜʢϔομʔϑο λʔͳͲʣΛ$IJME7JFX$POUSPMMFSʹ͍ͨ͠߹ɻ ˠBEEJUJPOBM4BGF"SFB*OTFUΛ͏ɻ ˠϔομʔʢϑολʔʣͷϑϨʔϜͷ༨നΛ $IJME7JFX$POUSPMMFSͰཧ͢Δ7JFXͷTBGF"SFB*OTFUTʹ͢͜ͱ ͕Ͱ͖Δɻ
@available(iOS 11.0, *) override func viewSafeAreaInsetsDidChange() { super.viewSafeAreaInsetsDidChange() let childVCAdditionalSafeAreaInsets = UIEdgeInsetsMake(self.childVCAdditionalSafeAreaInsetsTop, 0, 0, 0) self.childVC.additionalSafeAreaInsets = childVCAdditionalSafeAreaInsets }
͠ɺBEKVTUFE$POUFOU*OTFUΛΘͳ͍ TDSPMM7JFXDPOUFOU*OTFU"EKVTUNFOU#FIBWJPSOFWFS ͱ͢Δ߹ɻ ˠWJFX%JE-BZPVU4VCWJFXT ͰɺTDSPMM7JFXDPOUFOU*OTFUΛௐɻ DPOUFOU*OTFUͷௐ J04 override
func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() if #available(iOS 11.0, *) { self.tableView.contentInset = UIEdgeInsetsMake(self.view.safeAreaInsets.top, 0, self.view.safeAreaInsets.bottom, 0) self.tableView.scrollIndicatorInsets = self.tableView.contentInset } }
ʮBEKVTUFE$POUFOU*OTFUΛΘͳ͍߹ʯͱ΄΅ಉ͡ɻ ˠWJFX%JE-BZPVU4VCWJFXT ͷλΠϛϯάͰUPQ-BZPVU(VJEF CPUUPN-BZPVU(VJEFͷͱɺૠೖ͍ͨ͠JOTFUΛͯ͠ TDSPMM7JFXDPOUFOU*OTFUΛௐɻ ˠૠೖ͍ͨ͠JOTFUɺ7JFX$POUSPMMFSͷੜ࣌ʹ͢ɻ DPOUFOU*OTFUͷௐ
J04Ҏલ override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() if #available(iOS 11.0, *) { } else { self.topLayoutMarginConstraint.constant = 0 self.tableView.contentInset = UIEdgeInsetsMake(self.topLayoutGuide.length, 0, self.bottomLayoutGuide.length, 0) self.tableView.scrollIndicatorInsets = self.tableView.contentInset } }
DPOUFOU*OTFUͷௐ J04Ҏલ // ChildViewController @available(iOS, deprecated: 11.0, message:
"iOS11.0Ҏ߱ additionalSafeAreaInsets Ͱௐ͢Δɻ") private var additionalScrollViewContentInsetTop: CGFloat = 0.0 init(additionalScrollViewContentInsetTop: CGFloat) { self.additionalScrollViewContentInsetTop = additionalScrollViewContentInsetTop super.init(nibName: nil, bundle: nil) } ~~~ override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() if #available(iOS 11.0, *) { // do nothing } else { let contentInset = UIEdgeInsetsMake(self.topLayoutGuide.length + self.additionalScrollViewContentInsetTop, 0, self.bottomLayoutGuide.length, 0) self.scrollView.contentInset = contentInset self.scrollView.scrollIndicatorInsets = self.scrollView.contentInset } }
ࢀߟ <>4VCNJUUJOHJ04BQQTUPUIF"QQ4UPSF IUUQTEFWFMPQFSBQQMFDPNJPTTVCNJU <>6*4DSPMM7JFXBEKVTUFE$POUFOU*OTFU IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPOVJLJUVJTDSPMMWJFX BEKVTUFEDPOUFOUJOTFU MBOHVBHFPCKD <>6*4DSPMM7JFXDPOUFOU*OTFU"EKVTUNFOU#FIBWJPS IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPOVJLJUVJTDSPMMWJFX DPOUFOUJOTFUBEKVTUNFOUCFIBWJPS
MBOHVBHFPCKD <>J046*4DSPMM7JFXϓϩάϥϛϯάΨΠυ IUUQTEFWFMPQFSBQQMFDPNKQEPDVNFOUBUJPO6*4DSPMM7JFX@QHQEG
͋Γ͕ͱ͏͍͟͝·ͨ͠