サブクラス化するカスタム クラスがありUIViewます。やりたい構成がいくつかありますが、私が読んだことからself、メソッドでメッセージを使用することはお勧めできませんinit。これは私のinit方法です:
- (id) initWithMondayFirst:(BOOL)mondayFirst timeZone:(NSTimeZone*)timeZone andMonth:(NSDate*) month
{
if(self = [super initWithFrame:CGRectMake(0, 0, VIEW_WIDTH, VIEW_HEIGHT)]){
_timeZone = timeZone;
_mondayFirst = mondayFirst;
_currentMonth = [month monthBeginning];
[self configureNumberOfRows];
[self configureLimitations];
[self setBackgroundColor:[UIColor yellowColor]];
[self configureDimensions];
[self configureMonthLabel];
}
return self;
}
私の質問は、これらすべての構成メソッドをどこに置くべきですか? drawRect:メソッドに到達するまでにそれらが必要です。入れようと思ったけど、もったいないなぁ。ありがとう。
PS: これらの構成メソッドのほとんどは、クラスのプロパティの一部を構成します。