在我的UIViewController的viewDidLoad方法我如一个UIImageView实例调用阶段:添加一个UIImageView作为一个UIViewController的子视图,而无需使用IB
stage = [Stage viewWithParent:self];
,并调用此:
- (id)initWithParent:(UIView *)parent {
self = [self initWithFrame:CGRectZero];
if (!self)
return nil;
[parent addSubview:self];
return self;
}
+ (id) viewWithParent:(UIView *)parent {
return [[[self alloc] initWithParent:parent] autorelease];
}
我用前从UIImageView中调用它,并且一切都很好。图像可见,触摸事件已启用并作出响应。从UIViewController我得到一个窗口,但没有显示它,并没有触及记录。我错过了什么?
任何帮助表示赞赏!
谢谢// :)
看到这个------ http://stackoverflow.com/questions/3321374/cocoa-touch-adding-a-uiimageview-programmatically – 2011-12-08 12:30:24