【发布时间】:2014-06-10 03:51:23
【问题描述】:
我有一个cellForItemAtIndexPath 方法用于我的UICollectionView。重用标识符取决于 indexPath,所以我打算这样做:
var reuseIdentifier: String
if indexPath.row == 0 {
reuseIdentifier = "One"
} else if indexPath.row == 1 {
reuseIdentifier = "Two"
} else if indexPath.row == 2 {
reuseIdentifier = "Three"
}
var cell: UICollectionViewCell = collectionView.dequeueReusableCellWithIdentifier(reuseIdentifier, indexPath:indexPath)
这是正确的吗? reuseIdentifier 应该是可选字符串,还是普通字符串就可以了?
此外,在nil 的情况下,我是否正确处理了它?如果不是 2,reuseIdentifier 是 nothing,对吗? (这与 nil 不同?)我应该清楚地处理这个问题,对吧?
【问题讨论】:
标签: ios cocoa-touch swift