2015-10-06 1 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 хранилища, PSTCollectionViewItemTypeCell является членом PSTCollectionViewItemType перечисления:

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; 
} 

 Смежные вопросы

  • Нет связанных вопросов^_^