且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否应该全部引用声明为弱的以编程方式创建的子视图?

更新时间:2023-02-16 09:08:39

据我所知,子视图由控制器的主视图强烈引用.因此,将它们强引用是没有目的的,因为当主视图下降时,它们将无用.

As far as I know the subviews are strongly referenced by the main view of your controller. So there is no purpose of referencing them strong because the'll be useless when your main view goes down.

  1. 以其他方式,您可以通过编程创建子视图,然后添加到控制器的主视图中.
  2. 您控制器的主视图强烈引用了它们.
  3. 您会使用属性指向该视图.
  4. 当控制器的主视图是 deallocated 时,子视图也是如此.
  1. In other way, you create a subviews programmatically, and add them to your controller's main view.
  2. Your controller's main view references them strongly.
  3. And you point at this views with weak properties.
  4. When your controller's main view is deallocated, so are the subviews.