1

I am creating an ipad app where I add many UIImageviews over other UIViews and UIImageviews. I am not sure whether to use strong or weak while adding UIImageviews as subviews . I have created a project without ARC and now I am looking forward to convert it to ARC(because of "easy memory management") but still not sure about how should I type(weak/strong) my views.

4

1 回答 1

1

您是否真的要向视图添加子视图或在视图控制器中添加对子视图的引用?

如果您的父类是 UIView 的子类,那么您实际上是在向视图添加子视图。所以 addSubview 方法为你的视图添加一个强引用。您可以使用弱引用。

如果您的父类是 UIViewController 的子类,那么您并没有真正将子视图添加到视图中。因此,没有什么可以为您的对象添加强引用。使用强参考。

于 2012-02-27T13:13:29.153 回答