UIView是否保留其视图控制器 [英] Does a UIView retain its view controller

查看:102
本文介绍了UIView是否保留其视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UIView是否保留了它的关联视图控制器?

Does a UIView retain it's associated view controller?

例如,在以下代码中,视图由父视图保留。如果这个视图也保留了它的ViewController,所以我可以在loadView方法中释放控制器。

For example, in the following code the view is retained by the parent view. It would be handy if this view also retained its ViewController so that I could go ahead and release the controller in the loadView method.

- (void) loadView {

  ...

  MyViewController* ctrl = [[MyViewController alloc] init];
  [self.view addSubview: ctrl.view];
  [ctrl release];

}

另外,我想是要跟踪控制器作为实例变量,并在适当时释放它。

The alternative, I suppose, is to keep track of the controller as an instance variable and release it when appropriate.

感谢

推荐答案

(视图甚至不知道自己的viewController)

(A view doesn't even know its own viewController)

这篇关于UIView是否保留其视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆