Skip to content

Commit

Permalink
[Feat] #347 - 홈뷰 탭바 다시 클릭 시 스크롤 최상단으로 이동하도록 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
Guryss committed Nov 18, 2024
1 parent 4db8d98 commit 2144338
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ final class WSSTabBarController: UITabBarController, UITabBarControllerDelegate
navigationControllers.append(navigationController)
}

setViewControllers(navigationControllers, animated: true)
setViewControllers(navigationControllers, animated: false)
}

private func createNavigationController(normalImage: UIImage,
Expand Down Expand Up @@ -113,6 +113,11 @@ final class WSSTabBarController: UITabBarController, UITabBarControllerDelegate
return false
}

if let navigationController = viewController as? UINavigationController,
let homeViewController = navigationController.viewControllers.first as? HomeViewController {
homeViewController.scrollToTop()
}

return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class HomeView: UIView {

//MARK: - UI Components

private let scrollView = UIScrollView()
let scrollView = UIScrollView()
private let contentView = UIView()
let headerView = HomeHeaderView()
let todayPopularView = HomeTodayPopularView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ final class HomeViewController: UIViewController {
})
.disposed(by: disposeBag)
}

//MARK: - Custom Method

func scrollToTop() {
self.rootView.scrollView.setContentOffset(CGPoint(x: 0, y: -self.rootView.scrollView.contentInset.top), animated: true)
}
}

extension HomeViewController: UICollectionViewDelegateFlowLayout {
Expand Down

0 comments on commit 2144338

Please sign in to comment.