0

I have a scrollView with paging enables. I have a UIView as a subview of the scrollView. When the scrollView reaches the buttom of it's content, I'm turning scrolling off:

scrollView.scrollEnabled = false

because I'm doing other things that require dragging in a part of the scrollView (Yellow part). So the scrollViews offset locks at the buttom of the page. I want to be able to drag in the UIView (red), to enable scrolling of the scrollView, and thereby change the scrollviews content offset.

So I've added a UIPanGestureRecognizer to the UIView, which action enables scrolling of the scrollview. The problem is that, when I start panning on the UIView, I have to lift the finger and put it down again, before I can drag the scrollView.

Overview of view hierachy

Here's some code:

var scrollView: UIScrollView!
var someView: UIView!
var panAGes: UIGestureRecognizer!

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    scrollView = UIScrollView(frame: CGRectMake(0, 0, view.frame.width, view.frame.height))
    scrollView.contentSize = CGSizeMake(view.frame.width, view.frame.height * 2)
    scrollView.pagingEnabled = true
    scrollView.delegate = self
    someView = UIView(frame: CGRectMake(0, view.frame.height, view.frame.width, 100))
    someView.backgroundColor = UIColor.yellowColor()
    panAGes = UIPanGestureRecognizer(target: self, action: "panning:")

    someView.addGestureRecognizer(panAGes)
    scrollView.addSubview(someView)
    self.view.addSubview(scrollView)
 }

func scrollViewDidScroll(scrollView: UIScrollView) {
    // when page is locked
    if scrollView.contentOffset.y >= view.frame.height {
        scrollView.scrollEnabled = false
    }        
}

func panning(gesture: UIGestureRecognizer) {
        scrollView.scrollEnabled = true
}

How can I make the scrollView scroll, when the panning method is called? Thank You...

Wiingaard
  • 4,150
  • 4
  • 35
  • 67
  • What view or views do you have in the yellow part? – rob mayoff Oct 09 '15 at 20:51
  • I have a tableView, also scrolling horizontally... But it doesn't work either, if i don't add the tableView (empty yellow part).. – Wiingaard Oct 09 '15 at 20:52
  • So the yellow part contains a table view that scrolls horizontally but not vertically? – rob mayoff Oct 09 '15 at 22:16
  • Sorry, a tableView also scrolling _vertically_. But the problem is the same if i remove the tableview.. – Wiingaard Oct 09 '15 at 22:27
  • So, I don't know if this is the right terminology, but I want to enable scrolling on the scrollview and make it the responder to the panning event started at the View. Immidiatly after the panning starts. – Wiingaard Oct 09 '15 at 23:25

0 Answers0