如果我有一个像这样设置的类来自定义UIView.
@interface myView:UIView
- (id)init {
self = [super init];
if(self){
[self foo];
}
return self;
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
[self foo];
}
return self;
}
-(void) foo{
//Build UIView here
}
Run Code Online (Sandbox Code Playgroud)
为什么我会使用foo两次
myView *aView = [[myView alloc]init]];
Run Code Online (Sandbox Code Playgroud)
要么
myView *aView = [[myView alloc]initWithFram:aFrame];
Run Code Online (Sandbox Code Playgroud)