我想根据此处提到的文档修改单元格用户界面 enter link description here , 但不知道如何翻译 super
部分。
- (UICollectionViewCell *)collectionView:(JSQMessagesCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
JSQMessagesCollectionViewCell *cell = (JSQMessagesCollectionViewCell *)[super collectionView:collectionView cellForItemAtIndexPath:indexPath];
return cell;
}
这是我翻译的内容:
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
var cell = super.collectionView.cellForItemAtIndexPath(indexPath)
return cell!
}
最佳答案
如果您正在寻找正确的语法,这里是解决方案:
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell{
let cell = super.collectionView(collectionView, cellForItemAtIndexPath: indexPath) as! JSQMessagesCollectionViewCell
return cell
}
关于ios - 如何将 Objective-C 中的这段代码翻译成 Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32321254/