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
54
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
650
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
190
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
340
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
490
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
760
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
680
UICollectionView Compositional Layout
usamik26
0
800
Coding Swift with Visual Studio Code and Docker
usamik26
0
520
Swift Extension for Visual Studio Code
usamik26
2
1.1k
Other Decks in Programming
See All in Programming
[FEConf 2025] 모노레포 절망편, 14개 레포로 부활하기까지 걸린 1년
mmmaxkim
0
1.4k
🔨 小さなビルドシステムを作る
momeemt
3
660
ぬるぬる動かせ! Riveでアニメーション実装🐾
kno3a87
1
110
UbieのAIパートナーを支えるコンテキストエンジニアリング実践
syucream
2
820
レガシープロジェクトで最大限AIの恩恵を受けられるようClaude Codeを利用する
tk1351
4
1.6k
The state patternの実践 個人開発で培ったpractice集
miyanokomiya
0
160
KessokuでDIでもgoroutineを活用する / Go Connect #6
mazrean
0
140
パッケージ設計の黒魔術/Kyoto.go#63
lufia
3
420
詳解!defer panic recover のしくみ / Understanding defer, panic, and recover
convto
0
220
react-callを使ってダイヤログをいろんなとこで再利用しよう!
shinaps
1
130
More Approvers for Greater OSS and Japan Community
tkikuc
1
110
アセットのコンパイルについて
ojun9
0
100
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
100
5.8k
4 Signs Your Business is Dying
shpigford
184
22k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
How to train your dragon (web standard)
notwaldorf
96
6.2k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.8k
Optimising Largest Contentful Paint
csswizardry
37
3.4k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.7k
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 ্खʹ͓͏