UITableViewCell
カテゴリのメソッドをスウィズルしているときに予期しない動作が発生する
私の.m
ファイル:
#import "UICollectionViewCell+CostraintFix.h"
#import <objc/runtime.h>
@implementation UICollectionViewCell (CostraintFix)
+(void)load {
Method original_setBounds, swizzled_setBounds;
original_setBounds = class_getInstanceMethod(self, @selector(setBounds:));
swizzled_setBounds = class_getInstanceMethod(self, @selector(swizzled_setBounds:));
method_exchangeImplementations(original_setBounds, swizzled_setBounds);
}
- (void) swizzled_setBounds:(CGRect) bounds{
[self swizzled_setBounds:bounds];
self.contentView.frame = bounds;
}
@end
さて、私がプロジェクトを開始するとき、私はこれを持っています:
-[UINavigationButton swizzled_setBounds:]: unrecognized selector sent to instance 0x7fe2dbb301c0
- これは 100%
UICollectionViewCell
カテゴリです。 - この時点で、クラス
+(void) load
のみUITableViewCell
が渡されます (予想どおり)