UIView over UIScrollView prevents it from scrolling

I have UITableView

. Each cell has a view as shown below, a UIScrollView

in background and another view in UIScrollView.

The UIScrollView contains multiple images and the user should see them by scrolling to the right or left on the table cell. But since the second view ( red area ) covers the UIScrollview, the scrolling doesn't work when I swipe my finger in that area, but at the top of the red area, this is fine and works fine.

enter image description here

In another application that has this feature, I see that scrolling is possible at all heights of the cells, even if they have other views covering the background.

I would be grateful if you can share your suggestions with me :)

+3


source to share


6 answers


try disabling userInteraction in the view in the red area, this will allow the cables to pass through. this can be done via storyboard or just goview.userInteractionEnabled = false



+9


source


Save this line of code in the ViewDidLoad method:

    [self.view setExclusiveTouch:YES];

      

And if that doesn't work, add it for your table view



    [tableView setExclusiveTouch:YES];

      

Or else at the end, you can add a swipe gesture to the tableview cell and call the selector and do what should have been done.

0


source


Add a second view as a child of the firstView or ScrollView.

[scrollView addSubview:firstView];
[firstView addSubview:secondView];

      

0


source


The problem for me was that the view was not subordinate UIScrollView

. You can test this by setting a breakpoint somewhere in your class UIScrollView

or controller parent view and entering the following in the debugger window:

po myScrollView.subviews

      

Then check the output to make sure your item is in subzones.

0


source


    scrollView.isScrollEnabled = false

      

and handle scrolling through the code.

func scrollToPage(page: Int) {
    var frame = scrollView.frame
    frame.origin.x = frame.size.width * CGFloat(page)
    scrollView.scrollRectToVisible(frame, animated: true)
}

      

0


source


view.userInteractionEnabled = NO

      

-2


source







All Articles