Skip to content

Commit

Permalink
[iOS] BUG: 화면에서 뒤로 나가지 못 하는 문제 해결 #189
Browse files Browse the repository at this point in the history
  • Loading branch information
김수경 authored and 김수경 committed Feb 20, 2025
1 parent 54747fa commit 890b080
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ final class HomeViewController: BaseViewController<HomeReactor> {
.asDriver(onErrorJustReturn: "")
.drive(with: self) { owner, value in
let vc = KickRoomViewController(KickRoomReactor(value))

owner.navigationController?.pushViewController(vc, animated: false)

vc.modalPresentationStyle = .overFullScreen

owner.present(vc, animated: true)
}
.disposed(by: disposeBag)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,10 @@ final class KickRoomViewController: BaseViewController<KickRoomReactor> {
override func viewDidLoad() {
super.viewDidLoad()

navigationController?.interactivePopGestureRecognizer?.delegate = self
navigationController?.interactivePopGestureRecognizer?.isEnabled = true

setNotification()
setPopView()
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)

Expand Down Expand Up @@ -221,6 +219,12 @@ final class KickRoomViewController: BaseViewController<KickRoomReactor> {
)
}

private func setPopView() {
let panGesture = UIPanGestureRecognizer(target: self, action: #selector(handlePanGesture(_:)))

view.addGestureRecognizer(panGesture)
}

private func presentChattingView() {
guard let roomID = reactor.currentState.roomInfo?.roomDetail.roomInfo.roomID else { return }

Expand Down Expand Up @@ -266,6 +270,22 @@ final class KickRoomViewController: BaseViewController<KickRoomReactor> {
}
}

@objc
private func handlePanGesture(_ gesture: UIPanGestureRecognizer) {
let translation = gesture.translation(in: view)

if translation.y > 0 {
if gesture.velocity(in: view).y > 1000 {
navigationController?.popViewController(animated: true)
self.dismiss(animated: true, completion: nil)
}
}

if gesture.state == .ended || gesture.state == .cancelled {
gesture.setTranslation(.zero, in: view)
}
}


// MARK: - configure UI

Expand Down Expand Up @@ -358,5 +378,3 @@ extension KickRoomViewController: YTPlayerViewDelegate {
timeTrackingTimer = nil
}
}

extension KickRoomViewController: UIGestureRecognizerDelegate {}

0 comments on commit 890b080

Please sign in to comment.