我的課是UIImageView的子類。我創建了這樣的自定義初始化器UIImageView的子類中的自定義初始值設定項是否需要重寫initWithImage或initWithFrame初始值設定項?
@interface FishView : UIImageView
@end
@implementation FishView
- (id)initWithFishType:(FishType)fishType {
self = [super init];
if (self) {
//my custom initialization
}
return self;
}
是否有必要重寫initWithImage?
- (id)initWithImage:(UIImage)image
{
self = [super initWithImage:image];
if (self) {
[self initWithFishType:FTNone];
}
return self;
}
首先感謝您的快速解答。也許我把它與自定義類的覆蓋指定初始值設定項混合使用。 – Michael