在ScrollView中如果添加了button,一开始会出现button的按下效果不明显,此时会设置scrollView.delaysContentTouches = NO;来关闭延迟响应, 但是又会出现手指放在button上去做滑动,但是scrollView只会响应button的点击事件,而不去进行滑动.
要解决这个办法,需要重载UIScrollView这个类,并实现其中的touchesShouldCancelInContentView:方法,在方法中return YES就好啦.
但是会有人发现,为什么我重载了这个方法,但是打了断点却发现不调用这个方法呢?
看下外国友人的问答:
From what I've seen, you don't get touchesShouldCancelInContentView: or touchesShouldBegin:withEvent:inContentView: callbacks unless you have delaysContentTouches set to NO:
scrollView.delaysContentTouches = NO;这段说你重载的这俩方法,必须同时设置scrollView.delaysContentTouches = NO;
I got stuck on this for a while i