我使用NSTimer进行UICollectionView连续滚动,这是代码
let timer = NSTimer(timeInterval: 0.1, target: self, selector: #selector(HomeViewController.scrollToNextCard), userInfo: nil, repeats: true)
NSRunLoop.currentRunLoop().addTimer(timer!, forMode: NSDefaultRunLoopMode)
func scrollToNextCard(){
UIView.animateWithDuration(0.1, delay: 0.0, options: UIViewAnimationOptions.CurveEaseInOut, animations: {
// I am changing the contentOffset of collectionview for continuous scrolling
}, completion: {(finished:Bool) in
})
在滚动过程中点击任何可见单元格时,未调用委托方法 didSelectItemAtIndexpath 。如何在保持滚动集合视图的同时实现攻丝检测。请帮助谢谢
答案 0 :(得分:1)
我找到了相同的答案,我必须在动画块上添加AllowUserInteraction标志,如代码所示:
func scrollToNextCard(){
UIView.animateWithDuration(Constants.CardFlowTimeInterval, delay: 0.0, options: [.CurveEaseInOut,.AllowUserInteraction], animations: {
}, completion: {(finished:Bool) in
})
}