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

链接地址: http://www.djcxy.com/p/81999.html

上一篇: didAddSubview not working in ViewController

下一篇: DrawRect of UIView inside UIScrollView