How does UIView nextResponder know what the UIViewController is?

http://stackoverflow.com/questions/1587052/how-does-uiview-nextresponder-know-what-the-uiviewcontroller-is

找到一篇帖子讨论这个,但没有定论,应该是一个private api做的。

通过xcode的调试器,的确发现viewcontroller的view的确有一个_viewDelegate指针,它的值的确是它的viewcontroller的地址。

- (void)loadView {

NSLog(@"in loadview");

[self initWithNibName:@"rootView" bundle:nil];

[super loadView];

=====》在这里下断点,当super的loadview执行了以后,_viewDelegate就马上变成了self的值,说明这个值肯定是loadview里面做的

}

posted @ 2011-04-17 20:14  konggang  阅读(365)  评论(0编辑  收藏  举报