【发布时间】:2016-08-08 14:09:22
【问题描述】:
我有一个使用 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 不会被调用。如何在保持集合视图滚动的同时实现点击检测。请帮忙谢谢
【问题讨论】:
-
试试
NSRunLoopCommonModes而不是NSDefaultRunLoopMode。 -
不,那不行。
标签: ios uiscrollview uicollectionview uigesturerecognizer