티스토리 뷰
728x90
반응형
section 에 따라서 커스텀 셀 설정
UITableViewDataSource
section 별로 custom cell 을 리턴해주면 된다.
- IndexPath 의 section 에 따라서 custom 한 cell 을 리턴해주면된다.
마찬가지로 didSelectRowAt 메서드에서도 section 에 따라서 cell 을 present 할 수 있다.
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0 {
guard let topCell = tableView.dequeueReusableCell(withIdentifier: ScheduleListTopCell.identifier, for: indexPath) as? ScheduleListTopCell else { return UITableViewCell() }
topCell.selectionStyle = .none
return topCell
}
else if indexPath.section == 1 {
guard let middleCell = tableView.dequeueReusableCell(withIdentifier: DetailCell.identifier, for: indexPath) as? DetailCell else { return UITableViewCell() }
middleCell.accessoryType = .disclosureIndicator
return middleCell
}
else {
guard let bottomCell = tableView.dequeueReusableCell(withIdentifier: EditListCell.identifier, for: indexPath) as? EditListCell else { return UITableViewCell() }
bottomCell.accessoryType = .disclosureIndicator
return bottomCell
}
}728x90
반응형
'iOS' 카테고리의 다른 글
| iOS) UITalbeView Separator 없애기 (0) | 2021.07.20 |
|---|---|
| iOS) UITextView placeholder 효과 구현하기 (0) | 2021.07.20 |
| iOS) UITextField 가 비어있다면 UIButton 비활성화 시키기 (0) | 2021.07.20 |
| iOS) UIButton 눌러도 반응하지 않도록 하기 (0) | 2021.07.20 |
| iOS) modal 창 뒤에 View 없애지 않기 (0) | 2021.07.20 |
댓글
TAG
- WidgetKit
- IOS
- 2022 KAKAO TECH INTERNSHIP
- rxswift
- async/await
- SwiftUI
- configurable widget
- OpenSourceLibrary
- Notification
- containerBackground
- MVVM
- Algorithm
- YPImagePicker
- github
- WWDC
- Objective-C
- CloneCoding
- RxCocoa
- Swift
- 서버통신
- APNS
- projectsetting
- watchOS
- Protocol
- Widget
- urlsession
- UserDefaults
- MOYA
- Firebase
- WWDC22
최근에 올라온 글
최근에 달린 댓글
글 보관함
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
링크
- Total
- Today
- Yesterday