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
iosdc_2017.pdf
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Kyohei Ito
September 17, 2017
940
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
iosdc_2017.pdf
Kyohei Ito
September 17, 2017
More Decks by Kyohei Ito
See All by Kyohei Ito
flutter_kaigi_2025.pdf
kyoheig3
2
1k
layerx_20241129.pdf
kyoheig3
2
520
flutterkaigi_2024.pdf
kyoheig3
0
1.8k
flutter_kaigi_2021.pdf
kyoheig3
0
1.2k
flutter_kmm_1.pdf
kyoheig3
1
1.2k
ca.swift_10.pdf
kyoheig3
0
720
iosdc_2018.pdf
kyoheig3
2
3.2k
orecon_vol1.pdf
kyoheig3
4
1.8k
ca.swift_2.pdf
kyoheig3
9
1.4k
Featured
See All Featured
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
310
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
400
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
590
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
260
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.9k
First, design no harm
axbom
PRO
2
1.2k
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
850
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
620
Transcript
࠷ۙͷ͋ͷαʔϏεͷ ൪දͷ࣮Λඥղ͘ 2017/09/17 iOSDC
About Me ҏ౻ɹګฏ Github : KyoheiG3 Twitter : @KyoheiG3
None
None
։ൃॳͷཁ݅ • 300νϟϯωϧදࣔ • ԣεΫϩʔϧͷίϯςϯπͷϧʔϓʢແݶεΫϩʔϧʣ
ͬͨ͜ͱ • UIScrollView on UITableView • UICollectionView • UIScrollView on
UIScrollView • UIScrollView
UIScrollView on UITableView
UIScrollView on UITableView • શνϟϯωϧͷUITableViewΛฒΔ • ݟ͍͑ͯΔ෦͚ͩUITableViewΛฒΔ
શνϟϯωϧͷUITableViewΛฒΔ Good • ࣮ͷΠϝʔδ͕͠қ͍ • ݁ߏαΫοͱͰ͖Δ
શνϟϯωϧͷUITableViewΛฒΔ Bad • ϝϞϦ͕ࢮ͵ • ॎεΫϩʔϧ͕ॏ͍
ݟ͍͑ͯΔ෦͚ͩUITableViewΛฒΔ Good • ϝϞϦͷ༻ྔΛݮͰ͖Δ
ݟ͍͑ͯΔ෦͚ͩUITableViewΛฒΔ Bad • UITableViewͷ࠶ར༻͕ॏ͍ • ࣮͕ෳࡶʹͳΔ
ແݶεΫϩʔϧ • UITableViewͷxҐஔมߋͰରԠͰ͖ͦ͏
UITableViewॏ͍..
UICollectionView
https://github.com/KyoheiG3/CollectionViewGridLayout
CollectionViewGridLayout Good • Cellͷෑ͖٧Ίࣗମ݁ߏ͍͍ײ͡ • isPrefetchingEnabledfalseʹ͢Δ
isPrefetchingEnabled දࣔൣғΑΓൣғʹCellΛ४උ
isPrefetchingEnabled දࣔൣғΑΓൣғʹCellΛ४උ
CollectionViewGridLayout Bad • CellͷαΠζมߋΛ͢ΔΑ͏ͳΞχϝʔγϣϯ͕໘ • ແݶεΫϩʔϧ͕Πέͯͳ͍
ແݶεΫϩʔϧ delegateͱdataSourceଆͰͦΕΛҙࣝͤ͟ΔΛಘͳ͍
let list: [String] = ["1", "2", "3", "4", "5"] func
collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return list.count * 2 } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! CollectionViewCell cell.label.text = list[indexPath.item % list.count] return cell }
ແݶεΫϩʔϧ
ແݶεΫϩʔϧ
UICollectionViewCellͷ࠶ར༻Λ࠷దԽͰ͖ͳ͍...
UIScrollView on UIScrollView
https://github.com/KyoheiG3/InfiniteView
InfiniteView • UIScrollViewͰ࡞ͨ͠UITableViewͷΑ͏ͳͷ • Cellͷ࠶ར༻Λͯ͢ཧ • CellͷϨΠΞτʹAutoLayoutΛར༻ • ΠϯλʔϑΣΠεUICollectionViewͷΑ͏ͳײ͡
InfiniteView Good • ΞχϝʔγϣϯͳͲAutoLayoutશ։Ͱ࣮Ͱ͖ͨ • ίϯτϩʔϥʔଆεοΩϦ • ແݶεΫϩʔϧ
InfiniteView Bad • Cellͷ࠶ར༻ͳͲϨΠϠʔͳ෦ͷ࣮ͳͲෳࡶͩͬͨ • CellͷαΠζมߋͷΞχϝʔγϣϯ͕ෳࡶͩͬͨ • ͱʹ͔͘ෳࡶͩͬͨ
ॳ৺ʹؼΖ͏
UIScrollView
https://github.com/KyoheiG3/GridView
ཁ݅ • εϜʔζͳεΫϩʔϧΛՄೳʹ͢Δ • CellͷαΠζΛΞχϝʔγϣϯͰมߋ͢Δ͜ͱ͕Ͱ͖Δ • ͳΜͳΒ֦ॖ͍ͨ͠Μ͚ͩͲͱ͍͏ཁʹ͑Δ • ϖʔδϯάͰ͖ΔΑ͏ʹ͢Δ
֓ཁ • 1ຕͷUIScrollViewͷ্ʹCellͷView͕ࡌ͍ͬͯΔ͚ͩ • AutoLayoutະ༻ • ແݶεΫϩʔϧCellͷframeͷมߋ
ॲཧ • contentOffsetมߋલͱมߋޙͷࠩܭࢉ • ֦ॖͷ߹ࠩܭࢉ • ճస֦ॖͷΞχϝʔγϣϯ࣌ࠩܭࢉ
ࠩܭࢉ 1. දࣔൣғͷCellใΛArrayͰอ࣋ 2. contentOffset͕มߋ͞Εͨ͋ͱͷ දࣔൣғͷCellใΛܭࢉ 3. ඞཁແ͘ͳͬͨCellΛআ 4. ৽ͨʹද͕ࣔඞཁʹͳΔCellͷՃ
ࠩܭࢉ 1. දࣔൣғͷCellใΛArrayͰอ࣋ 2. contentOffset͕มߋ͞Εͨ͋ͱͷ දࣔൣғͷCellใΛܭࢉ 3. ඞཁແ͘ͳͬͨCellΛআ 4. ৽ͨʹද͕ࣔඞཁʹͳΔCellͷՃ
ࠩܭࢉ 1. දࣔൣғͷCellใΛArrayͰอ࣋ 2. contentOffset͕มߋ͞Εͨ͋ͱͷ දࣔൣғͷCellใΛܭࢉ 3. ඞཁແ͘ͳͬͨCellΛআ 4. ৽ͨʹද͕ࣔඞཁʹͳΔCellͷՃ
൪දʹΈࠐΉ
UILabelͷattributedTextͬͯ͘͢͝ॏ͍ • AttributedLabelͬͯͷΛ࡞ͬͨ
AttributedLabelͷύϑΥʔϚϯε • Viewʹdraw • intrinsicContentSizeͷݺͼग़͠Λඞཁ࠷ݶ
intrinsicContentSizeͱ • ίϯςϯπͷ༰ʹԠͯ͡αΠζ͕ࣗಈతʹมΘΔViewΛ࡞ Ͱ͖Δ • UILabelUIButton͕͜ΕʹରԠ͍ͯ͠Δ
UILabelͷڍಈ • invalidateIntrinsicContentSizeͷݺͼग़͠ var text: String? { didSet { invalidateIntrinsicContentSize()
} } var font: UIFont! { didSet { invalidateIntrinsicContentSize() } }
UILabelͷڍಈ • ίϯςϯπͷදࣔൣғΛࣗಈܭࢉ override var intrinsicContentSize: CGSize { // ίϯςϯπͷදࣔൣғΛܭࢉͯ͠ฦ͢
}
UILabelͷύϑΥʔϚϯε • දࣔαΠζ͕ܾ·͍ͬͯΔ߹ͦͷαΠζΛฦ͢1 override var intrinsicContentSize: CGSize { return bounds.size
} 1 UITableViewCellͳͲͷࣗಈܭࢉॲཧ͏·͘ಈ͔ͳ͘ͳΓ·͢ɻ
UILabelͷύϑΥʔϚϯε • AttributedLabelΛར༻͢Δ !
AbemaTVͷ൪දͷCell • αΠζͷมߋ͕໌֬ͳ߹ʹ invalidateIntrinsicContentSize ΛݺͿ • intrinsicContentSize͕ࢀর͞Ε ͨΒsizeThatFitsͰαΠζΛܭࢉ͠ ͯฦ͢
ϨΠΞτॲཧΛԆ͢Δ
ϨΠΞτͷԆॲཧ • දࣔʹؔ͢ΔॲཧΛαϒεϨουͰߦ͏͜ͱͰ͖ͳ͍ • Cell͕දࣔ͞Ε͔ͯΒLabelΛϨΠΞτ͢Δ·Ͱͷ࣌ؒΛ গ͚ͩ͠σΟϨΠ
viewModel.currentContent .debounce(0.1, scheduler: MainScheduler.instance) .do(onNext: { [weak self] slot in
guard let me = self else { return } me.timeLabel.text = "00" me.titleLabel.attributedText = "Title" me.detailLabel.text = "Detail" }) .subscribe(onNext: { [weak self] content in guard let me = self else { return } me.titleLabel.invalidateIntrinsicContentSize() me.detailLabel.invalidateIntrinsicContentSize() me.layoutIfNeeded() }) .disposed(by: disposeBag)
ύϑΥʔϚϯεΛ্͢Δʹ • intrinsicContentSizeΛ੍ޚ • ඞཁʹԠͯ͡Ԇॲཧ
࠷ۙͷ͋ͷαʔϏεͷ൪දͷ࣮Λඥղ͘ https://github.com/KyoheiG3/CollectionViewGridLayout https://github.com/KyoheiG3/InfiniteView https://github.com/KyoheiG3/GridView Github : KyoheiG3 Twitter : @KyoheiG3
Thanks!