How to Make the scroll of a TableView inside ScrollView behave naturally

后端 未结 13 2068
无人及你
无人及你 2020-12-07 08:22

I need to do this app that has a weird configuration.

As shown in the next image, the main view is a UIScrollView. Then inside it should have a UIPageView, and each

13条回答
  •  星月不相逢
    2020-12-07 08:44

    I tried the solution marked as the correct answer, but it was not working properly. The user need to click two times on the table view for scroll and after that I was not able to scroll the entire screen again. So I just applied the following code in viewDidLoad():

    tableView.addGestureRecognizer(UISwipeGestureRecognizer(target: self, action: #selector(tableViewSwiped)))
    scrollView.addGestureRecognizer(UISwipeGestureRecognizer(target: self, action: #selector(scrollViewSwiped)))
    

    And the code below is the implementation of the actions:

    func tableViewSwiped(){
        scrollView.isScrollEnabled = false
        tableView.isScrollEnabled = true
    }
    
    func scrollViewSwiped(){
        scrollView.isScrollEnabled = true
        tableView.isScrollEnabled = false
    }
    

提交回复
热议问题