didAddSubview在ViewController中不起作用
如果我使用iPhone SDK版本4.2在Xcode中使用基于视图的应用程序模板创建项目,并将此Objective-C代码添加到ViewController.m中,则| #pragma mark - 查看生命周期| 它不触发didAddSubview
的日志消息 -
- (void) loadView {
[super loadView]:
CGRect frame = CGRectMake(10.0, 10.0, 160, 230);
UIView *newView = [[[UIView alloc] initWithFrame:frame] autorelease];
[self.view addSubview:newView];
}
-(void) didAddSubview:(UIView *) subview {
NSLog(@"subview added %@", subview);
}
为什么在运行时不会触发事件处理程序?
-didAddSubview:
是UIView
上的一个方法,而不是UIViewController
。