250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- IOS
- SWIFT
- 풀스택
- effect
- iOS 개발자
- javascript
- iPhone
- react
- hover
- HTML
- html5
- xcode
- 백엔드
- php
- image
- button
- CSS
- MAC
- 비전공 개발자
- css3
- keyframes
- 개발자
- 애니메이션
- ipad
- 자바스크립트
- 프론트엔드
- Animation
- jQuery
- 비전공자
- front-end
Archives
- Today
- Total
비전공자 개발일기
Log Out 본문
728x90
SMALL
import UIKit
import FirebaseAuth
class ProfileViewController: UIViewController {
@IBOutlet var tableView: UITableView!
let data = ["Log Out"]
override func viewDidLoad() {
super.viewDidLoad()
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
tableView.delegate = self
tableView.dataSource = self
}
}
extension ProfileViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return data.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = data[indexPath.row]
cell.textLabel?.textAlignment = .center
cell.textLabel?.textColor = .red
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
let actionSheet = UIAlertController(title: "", message: "", preferredStyle: .actionSheet)
actionSheet.addAction(UIAlertAction(title: "Log Out", style: .destructive, handler: { [weak self] _ in
guard let strongSelf = self else { return }
do {
try FirebaseAuth.Auth.auth().signOut()
let vc = LoginViewController()
let nav = UINavigationController(rootViewController: vc)
nav.modalPresentationStyle = .fullScreen
strongSelf.present(nav, animated: true)
} catch {
print("Failed to log out")
}
}))
actionSheet.addAction(UIAlertAction(title: "Cancel", style: .cancel))
present(actionSheet, animated: true)
}
}
728x90
LIST
'SWIFT' 카테고리의 다른 글
Random Chinese character Generator (0) | 2023.01.29 |
---|---|
Memo App made by SwiftUI (0) | 2023.01.17 |
Firebase Auth(Email / Password Login) (0) | 2023.01.15 |
Choose a picture in iPhone's photo library(UIImagePickerController) (0) | 2023.01.14 |
MVC Pattern (0) | 2023.01.13 |