我有兩種類型UICollectionViewCell:一類是畫廊細胞,另一種是配方細胞。我們如何爲單個UICollectionView使用兩種類型的UICollectionViewCell?
有一個切換按鈕。 首次加載視圖時,圖庫單元格將用於在集合視圖中顯示。
但在點擊切換按鈕,我試圖加載另一個單元:(配方單元),但它崩潰說沒有物業(其實這是配方細胞的財產)圖庫細胞。
有沒有辦法來加載與其他細胞相同的集合視圖?
在此先感謝。
編輯:
if (isGalleryOnCollectionView) {
ProfileFollowerCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
NSString *followerName;
if ([[arr_followerNames objectAtIndex:indexPath.row] isEqualToString:@""]) {
followerName=[arr_followersEmail objectAtIndex:indexPath.row];
}
else{
followerName=[arr_followerNames objectAtIndex:indexPath.row];
}
NSLog(@"\n\n\n follower name is :: %@\n\n",followerName);
cell.lbl_followerName.text = followerName;
}else{
GalleryCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
cell.lbl_recipeName.text = [[[dict_profileData valueForKey:@"recipes"] valueForKey:@"name"] objectAtIndex:indexPath.row];
}
SOLUTION:
[self.profleCollectionView registerClass:[ProfileFollowerCell class] forCellWithReuseIdentifier:@"followercell"];
出隊它的工作原理可重複使用的標識符之前,從筆尖註冊之後。
郵政代碼' - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath'正在返回 – random 2015-02-09 16:26:57
@random,如果我加載一個類型的細胞說ProfileFollowerCell在集合視圖,如果我重裝的CollectionView,並嘗試使用它崩潰下一個單元格(它使用舊電池) – user3804063 2015-02-09 16:36:32
我試着重裝之前做出的CollectionView爲零,但不作品 – user3804063 2015-02-09 16:37:06