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
Multiple layout with UITableViewCell
Search
yashigani
November 30, 2015
Programming
3.6k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Multiple layout with UITableViewCell
関モバ #8
yashigani
November 30, 2015
More Decks by yashigani
See All by yashigani
Hatena Engineer Seminar #10
yashigani
0
2.4k
Dependency Injection in iOS Apps
yashigani
2
530
Lazy stored property
yashigani
3
2.2k
Code reviewing in iOS app development
yashigani
9
4.6k
Useful 3 techniques developing in iOS Apps
yashigani
0
1.6k
Introduction to WebKitPlus
yashigani
2
2.5k
Types in Swift
yashigani
5
2.4k
Swift with apps by Hatena
yashigani
13
30k
What's new WebKit.framework
yashigani
2
1.6k
Other Decks in Programming
See All in Programming
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
190
タクシーアプリ『GO』の バックエンド開発のおける AI利活用と若者のすべて
pyama86
3
2k
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
320
Oxlintのカスタムルールの現況
syumai
6
1.1k
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
5.3k
CSC307 Lecture 17
javiergs
PRO
0
320
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
110
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
2
730
A2UI という光を覗いてみる
satohjohn
1
130
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
390
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
170
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.3k
Featured
See All Featured
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
580
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
390
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.3k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
A Soul's Torment
seathinner
6
2.9k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
170
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
390
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
Context Engineering - Making Every Token Count
addyosmani
9
960
Amusing Abliteration
ianozsvald
1
200
Deep Space Network (abreviated)
tonyrice
0
170
Transcript
.VMUJQMFMBZPVUXJUI 6*5BCMF7JFX$FMM @yashigani ؔϞό #8
yashigani id:yashigani_w @yashigani Mobile Application Engineer http://yashigani.hatenablog.com Hatena
None
͋ΔͷͰ͖͝ͱ
None
None
ඍົʹҧ͏ʜ
͍͔ʹͯ͠ෳͷ ϨΠΞτΛ࣮ݱ͢Δ͔
• ίʔυͰϨΠΞτΛ͍͡Δ • xibΛෳ༻ҙ͍͚ͯ͠Δ
ίʔυͰ͍͡Δ࡞ઓ
• Pros • Δ͜ͱࣗମ୯७ • Cons • ফ͑ΔView • Auto
Layoutͷઃఆ͕͍͠ • ϨΠΞτͷશ༰Λ௫Έʹ͍͘
ෳͷYJCΛ͏࡞ઓ
• Pros • NSLayoutConstraintΛϓϩύςΟʹ͠ͳͯ͘Α͍ • Auto LayoutͷࢦఆΛ୯७ʹͰ͖Δ • viewࣗମͷϓϩύςΟΛ͍͚Ͱ͖Δ •
Cons • ෳͷxibΛϝϯςφϯε͢Δඞཁ͕͋Δ • ܾΊࣄ͕૿͑Δ(͍ճ͠ʹ͘͞)
࣮ύλʔϯ
class EntryCell: UITableViewCell { @IBOutlet weak var titleLabel: UILabel! @IBOutlet
weak var thumbnailView:UIImageView? var entry: Entry! }
protocol EntryCellRepresentable { var tableView: UITableView! { get } func
registerEntryCell() func dequeueEntryCell(entry: Entry, forIndexPath indexPath: NSIndexPath) -> EntryCell }
extension EntryCellRepresentable { func registerEntryCell() { let ids = ["EntryCell",
"EntryCellWithImage"] ids.forEach { let nib = UINib(nibName: $0, bundle: nil) tableView.registerNib(nib, forCellReuseIdentifier: $0) } } func dequeueEntryCell(entry: Entry, forIndexPath indexPath: NSIndexPath) -> EntryCell { let id = entry.hasImage ? "EntryCellWithImage" : "EntryCell" let cell = tableView.dequeueReusableCellWithIdentifier(id, forIndexPath: indexPath) as! EntryCell cell.entry = entry return cell } }
·ͱΊ
• xibΛ͚ΔͱAuto LayoutҎ֎͍͚Ͱ͖Δ • OptionalΛ্खʹ͓͏ • protocol extension࠷ߴ • UIStackViewૣ͘ΘͤΖ
͋Γ͕ͱ͏͍͟͝·ͨ͠