ios - 一如既往地从 [UICollectionViewCell] 转换为不相关的类型 'profileviewCell'

标签 ios swift

1) 我写了一个指向 UICollectionViewCell 的 profileViewCell.swift 2)我写了一个profileViewController.swift是指向所有的UICollectionViewDelegates

当我尝试像这样在 viewDidLoad 方法中添加代码时

NSTimer.scheduledTimerWithTimeInterval(0.01, target: self, selector: Selector("resetView"), userInfo: nil, repeats: false)

3) 在 resetView 方法中,我可以像这样调用 Collection View 出售第一个对象

函数重置 View (){

    let cell:profileViewCell = self.collectionView.visibleCells() as! profileViewCell
    self.reset(cell)

}

然后编译器显示错误和警告,如“一如既往地从 [UICollectionViewCell] 转换为不相关的类型 'profileviewCell'”,请帮助我,提前致谢

最佳答案

visibleCells 的调用返回一个单元格数组,但您试图将其转换为单个单元格并将其用作单个单元格 - 您不能那样做。您要么需要从数组中取出一个单元格进行处理,要么遍历所有单元格。

关于ios - 一如既往地从 [UICollectionViewCell] 转换为不相关的类型 'profileviewCell',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35499935/

相关文章:

android - 直接从浏览器(或从应用程序)发送到 whatsapp 组的链接

ios - 在方案而不是目标中设置构建变量

objective-c - iOS 上的 Objective C 数据缓存

ios - SwiftUI-无法搜索和切换列表

ios - 无法更改UINavigationBar提示颜色和字体

ios - 圆形 UIView 缩放动画有时会回到正方形

ios - 为什么当单击数组中的按钮时应用程序崩溃?

swift - 问题 : Saving Json data to Core Data

swift - Firebase 新用户 : Identity Toolkit API error

ios - NavigationController,将 Logo 保持在顶部,无需过渡