0

in my viewController I have an imageSlider which is above a UITableView.

I want to forward vertical swipeGesture from imageSlider to the underlying tableview. so when I swipe vertically on imageSlider, underlying tableView begins to scrolling. (tableview can scroll below imageSlider)

enter image description here

what I did:

I have created a custom view for my viewController View and have override hitTest:WithEvent: method:

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
    UIView *targetView = self.flexibleHeader;
    // Convert the point to the target view's coordinate system.
    // The target view isn't necessarily the immediate subview
    CGPoint pointForTargetView = [targetView convertPoint:point fromView:self];
    if (CGRectContainsPoint(targetView.bounds, pointForTargetView)) {
        // The target view may have its view hierarchy,
        // so call its hitTest method to return the right hit-test view
        UIView *finalView = [targetView hitTest:pointForTargetView withEvent:event];
        //final view should be UIButton or other UIControl element in RestaurantFlexibleHeader view
        if (![finalView isKindOfClass:[targetView class]]) {
            return finalView;
        }
    }
    
    return [super hitTest:point withEvent:event];
}

but the problem is that I can't detect swipe gesture from UIEvent. because allTouches property is empty! I can put imageSlider below tableView, so When I start to scroll vertically on imageSlider tableView begins to start scrolling. but how can I forward horizontal swipe and tap event to imageSlider?

so whats your idea? how do you handle this dilemma?

Community
  • 1
  • 1
Hashem Aboonajmi
  • 13,077
  • 8
  • 66
  • 75
  • When you say beneath, it is ambiguous. Do you mean beneath on the y axis (so the whole table view is visible) or z axis (so the top of the table view is partially obscured by the image view)? – TheBasicMind Nov 26 '15 at 16:43
  • z axis. tableView can goes under imageSlider. like appStore app on your iPhone. when you scroll vertically on the banner slider, tableView starts to scroll! – Hashem Aboonajmi Nov 26 '15 at 16:52
  • Possible duplicate of [Forward vertical scrolls from UIScrollView to a sibling UITableView](http://stackoverflow.com/questions/26967940/forward-vertical-scrolls-from-uiscrollview-to-a-sibling-uitableview) – Islam Nov 26 '15 at 17:34
  • In the App Store, the banner slider is most likely a cell in a collection view and doesn't remain in a fixed position. It doesn't slides vertically. Which exactly do you want ? You can do this with a table view, but actually I would do it in a UICollectionView (they probably do that for the App Store). You can add the images slider as a supplementary view in a fixed position at the top of the collection view. This makes it easy to change layouts in the future and gives more flexibility around the behaviour of the supplementary view (images slider). – TheBasicMind Nov 27 '15 at 09:31
  • in the appStore app bannerSlider is fixed at top, but collectionView supplementaryView is not fixed at top! another note is my custom imageSlider doesn't have a fixed height, as you scroll down, imageSlider scales down to 44pt. like safari app address bar – Hashem Aboonajmi Nov 28 '15 at 09:47

0 Answers0