@class UICollectionViewEx;
@protocol UICollectionViewExDelegate <NSObject, UICollectionViewDelegate>
@optional
- (void)willReloadDataByCollectionView:(UICollectionViewEx*)collectionView;
- (void)didReloadDataByCollectionView:(UICollectionViewEx*)collectionView;
@end
// 拡張機能を持たせたUICollectionView
@interface UICollectionViewEx : UICollectionView
@property (nonatomic, assign) id<UICollectionViewExDelegate> delegate;
@end
@implementation UICollectionViewEx
@dynamic delegate;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
- (void)reloadData
{
if ([self.delegate respondsToSelector:@selector(willReloadDataByCollectionView:)]) {
[self.delegate willReloadDataByCollectionView:self];
}
[super reloadData];
if ([self.delegate respondsToSelector:@selector(didReloadDataByCollectionView:)]) {
[self.delegate didReloadDataByCollectionView:self];
}
}
@end
コメントする