Skip to content

Commit dfe28cd

Browse files
committed
[fix] 마이페이지 뒤로가기 분기처리 로직 수정
1 parent 36eb39b commit dfe28cd

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

CA-PIN_IOS/CA-PIN_IOS/Screens/Login/ViewControllers/LoginViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class LoginViewController: UIViewController {
4040
super.viewDidLoad()
4141
self.view.backgroundColor = .white
4242
self.navigationController?.navigationBar.isHidden = true
43+
KeychainWrapper.standard.set(1, forKey: "loginVCFlag")
4344
layout()
4445
setTextField()
4546
keyboardObserver()

CA-PIN_IOS/CA-PIN_IOS/Screens/Login/ViewControllers/SplashViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class SplashViewController: UIViewController {
4141

4242
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
4343
if KeychainWrapper.standard.hasValue(forKey: "loginEmail") && KeychainWrapper.standard.hasValue(forKey: "loginPassword") {
44+
KeychainWrapper.standard.set(0, forKey: "loginVCFlag")
4445
if let email = KeychainWrapper.standard.string(forKey: "loginEmail"),
4546
let password = KeychainWrapper.standard.string(forKey: "loginPassword") {
4647
self.login(ID: email, PW: password)

CA-PIN_IOS/CA-PIN_IOS/Screens/Mypage/ViewControllers/MypageViewController.swift

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Moya
1010
import RxMoya
1111
import RxSwift
1212
import SnapKit
13+
import SwiftKeychainWrapper
1314
import Then
1415

1516
protocol PagingTabbarDelegate {
@@ -72,6 +73,8 @@ class MypageViewController: UIViewController {
7273
var categoryArray: [MyCategoryList] = [] /// 서버통신해서 카테고리 배열을 받아온다
7374
var categoryIdArray: [String] = [] /// 카테고리 아이디를 저장해놓는 배열 -> 카테고리 상세 페이지로 넘어갈 때 사용할 파라미터
7475

76+
var loginVCFlag: Int = 2
77+
7578
// MARK: - LifeCycle
7679
override func viewDidLoad() {
7780
super.viewDidLoad()
@@ -380,22 +383,20 @@ extension MypageViewController {
380383
}
381384
}
382385
@objc func backButtonClicked() {
383-
/// TODO: 자동로그인 여부 확인해서 분기처리
384-
// let mapVC = (self.navigationController?.children[2] as? MapViewController)!
385-
// self.navigationController?.popToViewController(mapVC, animated: true)
386-
// self.navigationController?.popViewController(animated: true)
387-
let mapVC = self.navigationController?.children[1] as? MapViewController
388-
print("@@")
389-
print(mapVC)
390-
print(self.navigationController?.children)
391-
// self.navigationController?.popToRootViewController(animated: true)
392-
if let vc = mapVC {
393-
print("~~~")
394-
self.navigationController?.popToViewController(vc, animated: true)
386+
var mapVC = self.navigationController?.children[1] as? MapViewController
387+
388+
loginVCFlag = KeychainWrapper.standard.integer(forKey: "loginVCFlag") ?? 2
389+
390+
if loginVCFlag == 0 {
391+
if let vc = mapVC {
392+
self.navigationController?.popToViewController(vc, animated: true)
393+
}
394+
} else {
395+
mapVC = self.navigationController?.children[2] as? MapViewController
396+
if let vc = mapVC {
397+
self.navigationController?.popToViewController(vc, animated: true)
398+
}
395399
}
396-
// else {
397-
// self.navigationController?.popToRootViewController(animated: true)
398-
// }
399400
}
400401
@objc func cafeTITestButtonClicked() {
401402
let cafetiVC = CafeTIViewController()

0 commit comments

Comments
 (0)