我的 UIScrollView 区域完美滚动,除非用户按下其中一个按钮:
var button:UIButton = UIButton.buttonWithType(UIButtonType.Custom) as UIButton
button.frame = CGRectMake(0,0,self.width, self.menuHeight)
button.addTarget(self, action: "buttonClicked:", forControlEvents: UIControlEvents.TouchUpInside)
button.tag = Int(itemNo)
scrollView.addSubview(button)
和按钮点击代码:
func buttonClicked(sender:UIButton)
{
var tag = sender.tag
println(tag)
}
即使用户将取景器移离按钮,TouchUpInside 方法似乎仍能保持控制。让 UIScrollView 区域可靠滚动的最佳方法是什么?
尝试设置delaysContentTouches
的财产UIScrollView
to NO
.
另外,您还可以设置canCancelContentTouches
财产给YES
. (It's YES
默认情况下,但以防万一。)
Reference https://developer.apple.com/library/prerelease/iOS/documentation/UIKit/Reference/UIScrollView_Class/index.html#//apple_ref/occ/instp/UIScrollView/delaysContentTouches (From docs) :
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)