didAddSubview not working in ViewController

If I create project using a View-based application template in Xcode using the iPhone SDK version 4.2 and add just this Objective-C code to the ViewController.m, right after | #pragma mark - View lifecycle | it does not trigger the log message in 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);
}

Why this doesn't trigger the event handler when run?


-didAddSubview:UIView上的一个方法,而不是UIViewController

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

上一篇: 使用UIScrollView子视图调整UIView的大小

下一篇: didAddSubview在ViewController中不起作用