【发布时间】:2016-07-26 20:53:35
【问题描述】:
UIView.animateWithDuration 和 UICollectionView Delegate 之间是否存在任何已知的故障?
如果我对用作 UIViewController 背景的 UIImageView 进行动画处理,我的 UICollectionViewCell 无法点击(根本不调用 shouldSelectItemAtIndexPath 等委托方法)
但是如果我注释掉动画背景的方法调用,单元格是可点击的,委托方法被调用并且一切正常。
顺便提一下,我有一个自定义 UIView 类和 nib,我将它们加载到我的 ViewController 上(UICollectionView 在这个视图中)。
这是我的代码:
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
customView = NSBundle.mainBundle().loadNibNamed("customView", owner: self, options: nil)[0] as! CustomView
customView.frame = childView.bounds
self.childView.addSubview(customView)
customView.initialize()
//self.rotateView()
}
func rotateView() {
UIView.animateWithDuration(18, delay: 0, options: .CurveLinear, animations: { () -> Void in
self.backgroundImage1.transform = CGAffineTransformRotate(self.backgroundImage1.transform, CGFloat(M_PI_2))
}) { (finished) -> Void in
self.rotateView()
}
}
这是自定义 UIView 的 initialize() 方法:
func initialize(){
collectionView.backgroundColor = UIColor.clearColor()
collectionView.registerNib(cellNib, forCellWithReuseIdentifier: "Cell")
self.collectionView.delegate = self
self.collectionView.dataSource = self
...
}
【问题讨论】:
标签: ios iphone swift delegates uicollectionview