1
我有我的故事板2個UICollectionView
,每個具有其自己的出口:兩個UICollectionViews在一個UIViewController中2個UICollectionViewCells
@IBOutlet weak var daysCollectionView: UICollectionView!
@IBOutlet weak var hoursCollectionView: UICollectionView!
在每一集的看法,我想用一個不同類型的細胞。所以我創建了一個DayCell
類和一個HourCell
類。
然後在cellForItemAtIndexPath:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
{
if collectionView == self.dayCollectionView
{
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("dayCell", forIndexPath: indexPath) as DayCell
...
return cell
}
else if collectionView == self.hourCollectionView
{
let cell: HourCell = collectionView.dequeueReusableCellWithReuseIdentifier("hourCell", forIndexPath: indexPath) as HourCell
...
return cell
}
}
我得到一個編譯器錯誤
失蹤有望迴歸UITableCellView」函數返回。
我完全失去了一些東西或在if
聲明中的回報在這種情況下不起作用嗎?
或者我只是在談論這個完全錯誤的?這似乎是每個人都在建議的答案。我只是無法讓它工作。
這不僅解決我的問題,但我覺得學歷的爲好。謝謝! – fedoroffn 2014-10-02 18:45:33