iOSでのカスタムView初期化コード
- (void)commonInit {
}
- (id)init {
self = [super init];
if (self) {
[self commonInit];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self commonInit];
}
return self;
}
AndroidでのカスタムView初期化コード
private void initComponents() {
}
public CustomView(Context context) {
super(context);
initComponents();
}
public CustomView(Context context, AttributeSet attrs) {
super(context, attrs);
initComponents();
}
XIBで定義したカスタムViewをコードでインスタンス化する
+ (CustomUIView *)view{
NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"CustomUIView" owner:nil options:nil];
return [array objectAtIndex:0];
}