0
我是一个从“Hacking with Swift”中读到一本书的人:Paul Hudson。我遵循所有的步骤,但几天前我碰到了一些我认为不应该的东西。我现在得到这个错误的过去一天,我以前使用过这个相同的方法,它的工作,但我不知道发生了什么或我碰到什么。谁能帮我?为什么我得到错误:“类型UICollectionView的值没有成员dequeueReusableCell”?
这里是我的代码:
import UIKit
class ViewController: UICollectionViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 10
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Person", for: indexPath) as! PersonCell
return cell
}
}
您发布的代码看起来很不错,它编译时没有错误。问题一定在其他地方。可以添加更多的细节到你的问题吗? – joern
基本上我正在关注这本书,书中没有提到会发生任何错误。此外,我以前使用过这种方法,它工作。我想我碰到了一些我不应该在UICollectionView.h文件中出现的东西。我希望这可以帮助。 –