uikit 2

[ iOS ] ๋ฐ์ดํ„ฐ ์œ ๋ฌด์— ๋”ฐ๋ผ CollectionView UI ๋ณ€๊ฒฝํ•˜๊ธฐ with DiffableDataSource, Snapshot

๊ธ€์„ ๊ฒŒ์‹œํ•œ ์ดํ›„ ์ฝ”๋“œ์— ๋ฌธ์ œ๊ฐ€ ์žˆ๋‹ค๋Š” ๊ฑธ ๋ฐœ๊ฒฌํ•ด ์ด๋ฅผ ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค!๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ๊นŒ์ง€ ์‹œํ–‰์ฐฉ์˜ค๊ฐ€ ๊ถ๊ธˆํ•˜์‹œ๋‹ค๋ฉด ์ด ๊ธ€ ๋ด์ฃผ์„ธ์š”~ [ iOS ์‹œํ–‰์ฐฉ์˜ค ] CollectionView์— Cell์ด ํ•˜๋‚˜๋งŒ ๋ณด์ด๋Š” ์ด์œ ๐Ÿ‘ฉ‍๐Ÿ’ป๋ฐฐ๊ฒฝ๐Ÿ‘ฉ‍๐Ÿ’ปChapterList๋ฅผ ๊ฐœ๋ฐœํ•˜๋˜ ์ค‘, ๋ถ„๋ช… item์ด 3๊ฐœ๊ฐ€ ์žˆ๋Š”๋ฐ cell์ด 1๊ฐœ๋งŒ ๋ณด์ด๋Š” ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค! ๊ทธ๋ž˜์„œ ์ด์ „์— ์ž‘์—…ํ–ˆ๋˜ BookList์—์„œ๋„ ํ™•์ธํ•ด ๋ณด๋‹ˆ ๋˜‘๊ฐ™์€ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค.. BookList88yhtserof.tistory.com         1๏ธโƒฃ ๊ตฌํ˜„ํ•˜๊ธฐ ์ „์— ๋จผ์ € ์•Œ์•„๋ณด๊ธฐ โ˜๏ธ ๊ตฌํ˜„ ๊ฐ„๋žต ์š”์•ฝCell๊ณผ Section, Item์„ BookList์™€ Empty ๋‘ ๊ฒฝ์šฐ๋กœ ๊ตฌ๋ถ„ํ•˜์—ฌ, ๋ฐ์ดํ„ฐ ์œ ๋ฌด๋ฅผ ํ™•์ธํ•œ ํ›„ DiffableDataSource์— Cell์„ ๋“ฑ..

iOS 2024.06.17

[ iOS ] cell ๋‚ด ๋ฒ„ํŠผ ์„ ํƒ ์ด๋ฒคํŠธ ๊ตฌํ˜„ (+ Delegate ํŒจํ„ด)

๊ณต๋ถ€ํ•œ ๋‚ด์šฉ์„ ์ •๋ฆฌํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค. ๋ฌธ์ œ ์‚ฌ์ง„ ๋‚ด ๋ฒ„ํŠผ ์„ ํƒํ•˜๊ธฐ 1. cell ๋‚ด ๋ฒ„ํŠผ ์ด๋ฒคํŠธ ๋ฐœ์ƒ์‹œํ‚ค๊ธฐ UICollectionViewControllerDelegate์˜ collectionView(_:didSelectItemAt:) ๋ฉ”์„œ๋“œ๋ฅผ ํ†ตํ•ด collectionView Cell์˜ ์„ ํƒ ์ด๋ฒคํŠธ๋ฅผ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋‹ค. ํ•˜์ง€๋งŒ ์ด ์ด๋ฒคํŠธ๋Š” cell์˜ ์ด๋ฒคํŠธ๋ฅผ ์˜๋ฏธํ•˜์ง€ cell ๋‚ด ๋ฒ„ํŠผ์˜ ์ด๋ฒคํŠธ๋ฅผ ์˜๋ฏธํ•˜์ง€๋Š” ์•Š๋Š”๋‹ค. ์šฐ๋ฆฌ๋Š” ๋ฒ„ํŠผ์ด cell ๋‚ด์— ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ๊ณ  ์žˆ์–ด์•ผ ํ•œ๋‹ค. collectionView(_:didSelectItemAt:) ๋ธ๋ฆฌ๊ฒŒ์ดํŠธ์— ํŠน์ •ํ•œ ์ธ๋ฑ์Šค์˜ ์•„์ดํ…œ์ด ์„ ํƒ๋˜์—ˆ์Œ์„ ์•Œ๋ฆฐ๋‹ค. ๋ฒ„ํŠผ์— ์„ ํƒ ์ด๋ฒคํŠธ๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด ํ•ด๋‹นํ•˜๋Š” ์•ก์…˜ ํ•จ์ˆ˜๊ฐ€ ํ˜ธ์ถœ๋˜๋ฏ€๋กœ, ์•ก์…˜ํ•จ์ˆ˜ ๋‚ด์— ์‚ฌ์ง„์„ ์„ ํƒํ•˜๋Š” ์ž‘์—…์„ ๊ตฌํ˜„ํ•˜๋ฉด ๋œ๋‹ค. ํ•˜..

iOS 2022.06.14
728x90