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
380
Apple HIG 正式名称クイズ結果発表 / HIG Quiz Result
usamik26
0
66
ゆめみ大技林製作委員会の立ち上げの話 / daigirin project
usamik26
0
250
@ViewLoadingプロパティラッパの紹介と自前で実装する方法 / @ViewLoading property wrapper implementation
usamik26
0
360
これからUICollectionViewを実践活用する人のためのガイド / Guide to UICollectionView
usamik26
1
610
Xcodeとの最近の付き合い方のはなし / Approach To Xcode
usamik26
2
530
UICollectionView Compositional Layout
usamik26
0
540
Coding Swift with Visual Studio Code and Docker
usamik26
0
350
Swift Extension for Visual Studio Code
usamik26
2
750
Other Decks in Programming
See All in Programming
From Spring Boot 2 to Spring Boot 3 with Java 22 and Jakarta EE
ivargrimstad
0
880
ONE WEDGE_company_guide
1wedge_one
0
370
StreamlitとTerraformでデータカタログを作った話
gussan0223
0
300
코틀린으로 멀티플랫폼 만들기
pangmoo
0
120
GitHub Actionsで泣かないためにやっておきたい設定 / Recommended GHA settings to avoid crying
pinkumohikan
3
480
StoreKit2によるiOSのアプリ内課金のリニューアル
kangnux
0
100
せっかくモデル図描くのなら、嬉しいことが多い方がいいよね!
kuboaki
1
3.1k
⼤規模⾔語モデルの拡張(RAG)が 終わったかも知れない件について
nearme_tech
22
15k
Folding Cheat Sheet #3
philipschwarz
PRO
0
110
チーム力を高めるスクラム実践法:カンバン公開と課題攻略について - ニフティのスクラムトーク Vol. 2 - NIFTY Tech Talk #18
niftycorp
PRO
1
110
Front-end application development, Symfony-style(s)
dunglas
2
1.9k
雑に思考を整理する技術と効能
konifar
55
25k
Featured
See All Featured
KATA
mclloyd
14
12k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
24
2.3k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
243
20k
Atom: Resistance is Futile
akmur
258
25k
The Cost Of JavaScript in 2023
addyosmani
14
3.8k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
658
120k
4 Signs Your Business is Dying
shpigford
175
21k
Fireside Chat
paigeccino
20
2.6k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
5
1.5k
What’s in a name? Adding method to the madness
productmarketing
PRO
15
2.6k
The Invisible Side of Design
smashingmag
294
49k
Agile that works and the tools we love
rasmusluckow
324
20k
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 ্खʹ͓͏