在比方说
- (void)applicationDidFinishLaunching:(UIApplication *)application {
...
[window addSubview:gameController.view];
...
}gameController的视图如何保持与gameController的关联?我已经检查了所有的调试器变量,除了一个布尔值标志,我看不到任何关联,它属于一个视图控制器。因此,视图被传递到视图层次结构(不一定要在窗口之外),但gameController将获得诸如shouldAutorotateToInterfaceOrientation之类的事件。如果不是在传递给gameController.view的UIView中隐藏了一些引用,那么这是在哪里被跟踪的
UIView *tmp = gameController.view;
[window addSubview:tmp];很明显,gameController知道tmp,但是window是如何在代码之后知道gameController的呢?
发布于 2009-10-29 04:59:24
UIViewController是UIResponder的后代,被插入到视图和视图的superview之间的响应器链中。因此,在UIViewController管理的视图上调用nextResponder将返回UIViewController的所述实例。
这就是像shouldAutorotateToInterfaceOrientation:这样的事件在UIResponder实例的层次结构中向上传递的方式。在figure 3.1 in the iPhone Application Programming Guide中可以看到显示这一点的图表。
https://stackoverflow.com/questions/1276494
复制相似问题