2015-10-06 22 views
0

我已經完全從我的項目中刪除PSTCollectionView,在某一時刻,我收到以下錯誤,找不到PSTCollectionViewItemTypeCell。我意識到,我需要用UICollectionView中的某些內容替換它,但是我沒有找到它。重組代碼從PSTCollectionView到UICollectionView

有沒有人遇到過(PSTCollectionView/UICollectionView)那麼請給我一個代碼和平的替代方案。

從iOS 6.0及以上版本這是一個罕見的問題 - 人們可以順利升級到UICollectionView。不過,我正在運行一箇舊項目,並且需要針對iOS 9.0進行完全重構。

請幫忙。

這裏是有問題的代碼:

- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UICollectionViewLayoutAttributes *attributes = (UICollectionViewLayoutAttributes *)[super layoutAttributesForItemAtIndexPath:indexPath]; 
    if ([attributes representedElementCategory] == PSTCollectionViewItemTypeCell) { 
     //some good code. 
    } 
    return attributes; 
} 

回答

0

可以從PSTCollectionView庫看到,PSTCollectionViewItemTypeCellPSTCollectionViewItemType枚舉的成員:

typedef NS_ENUM(NSUInteger, PSTCollectionViewItemType) { 
    PSTCollectionViewItemTypeCell, 
    PSTCollectionViewItemTypeSupplementaryView, 
    PSTCollectionViewItemTypeDecorationView 
}; 

這實質上是UICollectionElementCategory等價的:

typedef enum { 
    UICollectionElementCategoryCell, 
    UICollectionElementCategorySupplementaryView, 
    UICollectionElementCategoryDecorationView 
} UICollectionElementCategory; 

它應該只是一個替換另一個的情況:

- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UICollectionViewLayoutAttributes *attributes = (UICollectionViewLayoutAttributes *)[super layoutAttributesForItemAtIndexPath:indexPath]; 
    if ([attributes representedElementCategory] == UICollectionElementCategoryCell) { 
     //some good code. 
    } 
    return attributes; 
}