开发者

didAddSubview not working in ViewController

开发者 https://www.devze.com 2023-02-14 23:45 出处:网络
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 life

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 %@", su开发者_StackOverflow中文版bview);
}

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


-didAddSubview: is a method on UIView, not on UIViewController.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号