Reputation: 2680
I have a UITableView
, Each cell has a view like below image, a UIScrollView
in background and another view on the UIScrollView.
UIScrollView contains multiple images and user should be able to see them by swiping right or left on the table cell, But as second View (red area) covered UIScrollview, Scrolling not work when I swipe my finger in this area, But in the top of red area it's ok and works perfect.
I see in the other application that have this feature that scrolling is possible in all cell height even when they have other views that covered the background.
I should be grateful if you share your suggestions with me :)
Upvotes: 7
Views: 4468
Reputation: 2167
scrollView.isScrollEnabled = false
and handle the scrolling by code.
func scrollToPage(page: Int) {
var frame = scrollView.frame
frame.origin.x = frame.size.width * CGFloat(page)
scrollView.scrollRectToVisible(frame, animated: true)
}
Upvotes: 0
Reputation: 2274
For me the issue was that the view was not a subview of the UIScrollView
. You can check this by setting a breakpoint somewhere in your UIScrollView
or the parent view controller class and entering the following in your debugger window:
po myScrollView.subviews
Then check the output to make sure that your element is within the subviews.
Upvotes: 0
Reputation: 1942
Add Second view as a subview of firstView or ScrollView.
[scrollView addSubview:firstView];
[firstView addSubview:secondView];
Upvotes: 0
Reputation: 1013
Keep this line of code in ViewDidLoad method:
[self.view setExclusiveTouch:YES];
And if this doesn't work add it for your tableview
[tableView setExclusiveTouch:YES];
Or else at the end you can add the swipe gesture to the tableview cell and call the selector and do which intended to be done.
Upvotes: 0
Reputation: 11597
try disable userInteraction on the view in the red area, this will allow touches to pass though it. this can be done through the storyboard, or just go view.userInteractionEnabled = false
Upvotes: 12