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
580
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
140
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
300
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
450
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
710
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
640
UICollectionView Compositional Layout
usamik26
0
720
Coding Swift with Visual Studio Code and Docker
usamik26
0
480
Swift Extension for Visual Studio Code
usamik26
2
970
Other Decks in Programming
See All in Programming
Multi Step Form, Decentralized Autonomous Organization
pumpkiinbell
1
660
AIの力でお手軽Chrome拡張機能作り
taiseiue
0
170
チームリードになって変わったこと
isaka1022
0
190
データの整合性を保つ非同期処理アーキテクチャパターン / Async Architecture Patterns
mokuo
41
15k
いりゃあせ、PHPカンファレンス名古屋2025 / Welcome to PHP Conference Nagoya 2025
ttskch
1
270
Honoとフロントエンドの 型安全性について
yodaka
4
250
TokyoR116_BeginnersSession1_環境構築
kotatyamtema
0
110
ISUCON14公式反省会LT: 社内ISUCONの話
astj
PRO
0
180
Amazon Bedrock Multi Agentsを試してきた
tm2
1
280
さいきょうのレイヤードアーキテクチャについて考えてみた
yahiru
3
730
SpringBoot3.4の構造化ログ #kanjava
irof
2
970
CI改善もDatadogとともに
taumu
0
110
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.3k
Raft: Consensus for Rubyists
vanstee
137
6.8k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
540
Bash Introduction
62gerente
610
210k
Thoughts on Productivity
jonyablonski
69
4.5k
Testing 201, or: Great Expectations
jmmastey
41
7.2k
Docker and Python
trallard
44
3.3k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
How to train your dragon (web standard)
notwaldorf
90
5.8k
The Pragmatic Product Professional
lauravandoore
32
6.4k
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 ্खʹ͓͏