【发布时间】:2016-05-31 17:01:16
【问题描述】:
1) 我写了一个指向 UICollectionViewCell 的 profileViewCell.swift 2)我写了一个profileViewController.swift 是指向所有UICollectionViewDelegates
当我尝试像这样在 viewDidLoad 方法中添加代码时
NSTimer.scheduledTimerWithTimeInterval(0.01, target: self, selector: Selector("resetView"), userInfo: nil, repeats: false)
3) 在 resetView 方法中,我可以调用一个集合视图,像这样出售第一个对象
函数 resetView(){
let cell:profileViewCell = self.collectionView.visibleCells() as! profileViewCell
self.reset(cell)
}
然后编译器显示错误和警告,例如“像往常一样从 [UICollectionViewCell] 转换为不相关的类型 'profileviewCell'”请帮助我,在此先感谢
【问题讨论】:
-
正如@Wain 所说,您将在 visibleCells 调用中获得许多单元格。如果您想执行某些操作,请遍历它们。您可以使用
map,或其变体之一或任何 for/while/repeat 循环。如果对您有帮助,请不要忘记投票并接受他的回答。这样做会鼓励其他人在网站上回答您未来的问题。顺便说一句 - 欢迎来到该网站。