我有一个带分页功能的scrollView。我有一个UIView作为scrollView的子视图。当scrollView到达其内容的底部时,我正在关闭滚动:
scrollView.scrollEnabled = false
因为我正在做其他需要拖动scrollView(黄色部分)的部分内容。因此,scrollViews偏移锁定在页面的底部。我希望能够在UIView(红色)中拖动,以启用scrollView的滚动,从而更改scrollviews内容偏移。
所以我在UIView中添加了一个UIPanGestureRecognizer
,该动作可以滚动滚动视图。
问题是,当我开始在UIView上进行平移时,我必须抬起手指再将其放下,然后才能拖动scrollView。
以下是一些代码:
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
}
调用平移方法时如何进行scrollView滚动? 谢谢......