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
Auto Layout Tips
Search
USAMI Kosuke
November 30, 2015
Programming
0
50
Auto Layout Tips
http://kanmoba.connpass.com/event/22648/
USAMI Kosuke
November 30, 2015
Tweet
Share
More Decks by USAMI Kosuke
See All by USAMI Kosuke
Onsager代数とその周辺 / Onsager algebra tsudoi
usamik26
0
600
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
160
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
310
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
460
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
720
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
650
UICollectionView Compositional Layout
usamik26
0
750
Coding Swift with Visual Studio Code and Docker
usamik26
0
490
Swift Extension for Visual Studio Code
usamik26
2
1k
Other Decks in Programming
See All in Programming
List とは何か? / PHPerKaigi 2025
meihei3
0
310
Firebase Dynamic Linksの代替手段を自作する / Create your own Firebase Dynamic Links alternative
kubode
0
160
2025/3/18 サービスの成長で生じる幅広いパフォーマンスの問題を、 AIで手軽に解決する
shirahama_x
0
160
AtCoder Heuristic First-step Vol.1 講義スライド
terryu16
2
960
Kubernetesで実現できるPlatform Engineering の現在地
nwiizo
2
1.6k
Devin , 正しい付き合い方と使い方 / Living and Working with Devin
yukinagae
1
500
RubyKaigiで手に入れた HHKB Studioのための HIDRawドライバ
iberianpig
0
180
今から始めるCursor / Windsurf / Cline
kengo_hayano
0
110
アーキテクトと美学 / Architecture and Aesthetics
nrslib
12
2.9k
Preact、HooksとSignalsの両立 / Preact: Harmonizing Hooks and Signals
ssssota
1
230
AtCoder Heuristic First-step Vol.1 講義スライド(山登り法・焼きなまし法編)
takumi152
3
950
バックエンドNode.js × フロントエンドDeno で開発して得られた知見
ayame113
4
1.2k
Featured
See All Featured
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.2k
Building a Modern Day E-commerce SEO Strategy
aleyda
39
7.2k
Testing 201, or: Great Expectations
jmmastey
42
7.3k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
227
22k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Automating Front-end Workflow
addyosmani
1369
200k
How STYLIGHT went responsive
nonsquared
99
5.4k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
KATA
mclloyd
29
14k
Become a Pro
speakerdeck
PRO
27
5.2k
Thoughts on Productivity
jonyablonski
69
4.5k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Transcript
Auto Layout Tips USAMI Kosuke Fenrir Inc.
Auto Layout → iOS / OS X ͰͷϏϡʔͷϨΠΞτख๏ → ੍Λఆٛ͢Δ͜ͱͰαΠζҐஔΛࣗಈܭࢉ
→ ैདྷͷϑϨʔϜϕʔεϨΠΞτͱൃ͕ҟͳΔ
None
UIKit σβΠϯύλʔϯͱ Auto Layout → UIScrollView ͱ Auto Layout →
UITableView ͱ Auto Layout → UICollectionView ͱ Auto Layout → ͜ΕΒͷΈ߹ΘͤҊ֎͍ͨΜ
UIScrollView & Auto Layout
͏·͍͔͘ͳ͍ύλʔϯ → UIScrollView ͷதͷ View ͷαΠζ͕ Auto Layout Ͱܾ·Βͳ͍ →
contentSize ΛίʔυͰઃఆ͢Δඞཁ͕ग़ͯ͘Δ → దͳ contentSize ΛͲ͏༩͑Δ͔͘͠ͳΔ
Content View → ·ͣ UIScrollView ͷଆʹ Content View Λ࡞Δ →
UIScrollView ͱ Content View ͱͷ্Լࠨӈͷ֤ล ʹ੍Λఆٛ͢Δ → ͜ΕͰ contentSize = Content View ͷαΠζͱͳ Δ
͏·͍͘͘ύλʔϯ → Content View ͷαΠζΛ UIScrollView ͷ ֎ଆ ʹ ͋Δཁૉ͔Βܾ·ΔΑ͏ʹ͢Δ
→ ྫ͑࣍ͷΑ͏ͳ֊ͷͱ͖ → (1) UIView - (2) UIScrollView - (3) Content View → (3) ͷαΠζ͕ (1) ͔Βܾ·ΔΑ͏ʹ͢Δ → ʢྫ͑ɺ෯͕͍͠ͱ͔ʣ
UIScrollView & Auto Layout → ͜ΕͰ Auto Layout ͚ͩͰ݁͢Δ →
contentSize ΛίʔυͰઃఆ͢Δඞཁ͕ͳ͘ͳΔ
UITableView & Auto Layout
UITableView → UITableViewDelegate / UITableViewDataSource → Cell ͷੜͷલʹɺCell ͷߴ͞Λฦ͢ඞཁ͕͋Δ →
Cell ͷߴ͕͞ݻఆͰ͋Εޮ͕ྑ͍ઃܭ
ߴ͕͞ݻఆͰͳ͍ͱ͖ → Cell ͷߴ͕͞ݻఆͰͳ͍ͱ͖͋·Γྑ͘ͳ͍ → ߴ͞ΛΔͨΊʹԾʹ Cell Λੜ͢Δʁ → ಛʹ
Auto Layout ͱ૬ੑ͕ѱ͍
Self Sizing Cell (iOS 8) → tableView:estimatedHeightForRowAtIndexPath: Ͱ Ծͷߴ͞Λฦ͢ →
tableView:heightForRowAtIndexPath: Ͱ UITableViewAutomaticDimension Λฦ͢ → ͜ΕͰ Auto Layout Ͱܾ·Δߴ͕͞ Cell ͷߴ͞ʹ
UITableView & Auto Layout → ͜ΕͰ Auto Layout ͚ͩͰ݁͢Δ →
Ծͷ Cell ͱ͔࡞Βͳ͍͍ͯ͘
ҙ : Storyboard ্ͷઃఆ → Storyboard ্Ͱ UITableViewCell ͷߴ͞ೖྗཁ →
Cell ͷߴ͞ͱ Content View ͷߴ͞Λ߹ͤ͞Δ → Content View ͷϨΠΞτΛΈͳ͕ΒɺͦΕʹ ͋Θͤͯ Cell ͷߴ͞Λௐɾɾɾʢਖ਼ͩΔ͍ʣ
UICollectionVi ew & Auto Layout
UICollectionView → ઃܭ UITableView Λ౿ऻ → UICollectionViewLayout Ͱ༷ʑͳϨΠΞτ → ͜͜Ͱ
UICollectionViewFlowLayout Λѻ͏
αΠζ͕ݻఆͰͳ͍ͱ͖ → Γઌʹ Cell ͷαΠζΛฦ͢ඞཁ͕͋Δ → Auto Layout ͱ૬ੑ͕ѱ͍
Self Sizing Cell (iOS 8) → estimatedItemSize ʹԾͷαΠζΛฦ͢ ʢUISizeZero Ҏ֎ʣ
→ itemSize ઃఆ͠ͳͯ͘ྑ͍ → ͜ΕͰ Auto Layout ͷαΠζ͕ Cell αΠζʹ
UICollectionView & Auto Layout → ͜ΕͰ Auto Layout ͚ͩͰ݁͢Δ →
Ծͷ Cell ͱ͔࡞Βͳ͍͍ͯ͘
Auto Layout ্खʹ͓͏