I'm Presenting UIPageViewController, each page has UItableView. Pull-down gesture to dismiss not working in UIPageViewControllerTransitionStyle.scroll, but it's working fine in pageCurl style.
PageViewController
class PageViewController: UIPageViewController, UIPageViewControllerDataSource {
let pages: [UIViewController]
init(pages: [UIViewController]) {
self.pages = pages
super.init(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
self.dataSource = self
if let viewController = self.pages.first {
self.setViewControllers([viewController], direction: .forward, animated: true)
}
}
//MARK: UIPageViewControllerDataSource
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
guard let index = self.pages.firstIndex(of: viewController), index + 1 < tabVsViewController.count else {
return nil
}
return self.pages[index + 1]
}
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
guard let index = self.pages.firstIndex(of: viewController), index - 1 >= .zero else {
return nil
}
return self.pages[index - 1]
}
}
let bottomView = PageViewController(pages: viewControllers)
bottomView.preferredContentSize = CGSize(width: self.view.bounds.width ?? 0.0, height: 300.0)
bottomView.modalPresentationStyle = .formSheet
let sheetPresentation = bottomView.sheetPresentationController
sheetPresentation?.detents = [.medium(), .large()]
sheetPresentation?.selectedDetentIdentifier = .medium
sheetPresentation?.preferredCornerRadius = 20.0
sheetPresentation?.prefersGrabberVisible = true
self.present(bottomView, animated: true, completion: nil)