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
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.7k
Bash Introduction
62gerente
615
220k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
330
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
870
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
580
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.4k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
400
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
A Modern Web Designer's Workflow
chriscoyier
698
190k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
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!