์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
- TCA
- rxcocoa
- ํ๋ก๊ทธ๋๋จธ์ค
- reactorkit
- combine
- ํจ์คํธ์บ ํผ์ค
- Flutter
- raywenderlich
- tableView
- Lv2
- UIKit
- Xcode
- node.js
- CollectionView
- SnapKit
- realm
- Kuring
- arkit
- ios
- designpattern
- swift
- ๋ฐฑ์ค
- Swfit
- XCTest
- MVVM
- visionOS
- RxSwift
- BFS
- SwiftUI
- BOJ
- Today
- Total
lgvv98
[iOS] tableViewCell Swipe Action ๊ตฌํํ๊ธฐ ๋ณธ๋ฌธ
[iOS] tableViewCell Swipe Action ๊ตฌํํ๊ธฐ
๐ฅ ์บ๋ฟ๋งจ 2022. 5. 5. 14:11tableViewCell Swipe Action ๊ตฌํํ๊ธฐ
โ ์ด๋ฒ ์๊ฐ์๋ tableViewCell Swipe Action์ ๊ตฌํํด๋ณด์
์ง์ ์ ํ ๋ฌธ์๋ฅผ ์ฝ์ด๋ณด๋ ๊ฒ์ ์ถ์ฒํ์ง๋ง, ์ด ํฌ์คํ ์์๋ ์ ๋ง ๊ฐ๋ตํ๊ฒ ์ด๋ป๊ฒ ์ฌ์ฉํ๋ ์ง๋ง ์์๋ณด์.
์ด๋ฒ ํฌ์คํ ์์๋
1. tableView์์ leading๊ณผ trailing swipe๋ฅผ ์ง์ํด์ฃผ๋ ๋ฉ์๋๋ฅผ ์ฌ์ฉํ์ฌ ๊ตฌํํ๋ ๊ฒ
2. editStyle์ ๋ฉ์๋๋ฅผ ํ์ฉํ์ฌ ๊ตฌํํ๋ ๊ฒ
์ ๋ณผ ์์ ์ด๋ค.
โ 1. tableView์์ leading๊ณผ trailing swipe๋ฅผ ์ง์ํด์ฃผ๋ ๋ฉ์๋๋ฅผ ์ฌ์ฉํ์ฌ ๊ตฌํํ๋ ๊ฒ
func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
// TODO: ์ถํ์ ๊ณต์ง ๋ณด๊ดํจ ๊ธฐ๋ฅ ์ถ๊ฐ
let subscribeAction = UIContextualAction(
style: .normal,
title: nil
) {
action, view, completionHandler in
completionHandler(true)
}
subscribeAction.backgroundColor = .systemYellow
subscribeAction.image = UIImage(systemName: "archivebox.fill")
return UISwipeActionsConfiguration(actions: [subscribeAction])
}
์ฝ๋์ ๋ํ ๋ณ์๋ฅผ ์ ์ธํ๋ค.
completionHandler(true) ์ด ์ฝ๋๋ ์ก์ ๋ฒํผ์ ํด๋ฆญํ๋ฉด ์ก์ ์ด ์ฌ๋ผ์ ธ์ผ๊ฒ ์ง?
๊ทธ ๋ถ๋ถ์ ์ฒ๋ฆฌํด์ฃผ๋ ์ฝ๋์ด๋ค.
โ UI ์์
โ 2. editStyle์ ๋ฉ์๋๋ฅผ ํ์ฉํ์ฌ ๊ตฌํํ๋ ๊ฒ
func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle {
return .delete
}
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
switch editingStyle {
case .delete:
tableView.beginUpdates()
lockerNotices.remove(at: indexPath.row)
tableView.deleteRows(at: [indexPath], with: .fade)
tableView.endUpdates()
default:
break
}
}
'iOSํ๋ก์ ํธ > โ๏ธ Kuring' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[SwiftUI] List Row ์ ํํ๊ธฐ(TableView didSelectRow) (0) | 2022.05.30 |
---|---|
[iOS] Thread 1: "Attempt to insert non-property list object () for key ~ (0) | 2022.05.05 |
[iOS] Indicator customizing (feat. Lottie) (0) | 2022.04.30 |
[iOS] Haptic Feedback์ ๋ํด์ ์์๋ณด์๐ฃ (0) | 2022.03.21 |
[iOS] inAppReview(StoreKit)โจ (0) | 2022.03.06 |