何时调用layoutSubviews方法?

编程入门 行业动态 更新时间:2024-10-14 10:39:08
本文介绍了何时调用layoutSubviews方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在浏览教程,提到以下方法:

I am going through a tutorial that mentions the following method:

-(void)layoutSubviews

位于CustomerCell.m

located in CustomerCell.m

此方法何时调用应用执行?是自动调用吗?我没有看到任何回调。

When is this method called during the app execution? Is it automatically invoked? I dont see any callback.

推荐答案

你会找到答案 here

编辑:直接从博客中复制:

copied directly from the blog:

  • init不会导致调用layoutSubviews(duh)
  • addSubview导致在视图上调用layoutSubviews正在添加,它被添加到(目标视图)的视图,以及目标视图的所有子视图
  • setFrame智能调用视图上的layoutSubviews,只有在尺寸参数为框架是不同的
  • 滚动UIScrollView导致在scrollView上调用layoutSubviews,并且它是superview
  • 旋转设备只调用父项上的layoutSubview view(响应的viewControllers主视图)
  • removeFromSuperview - 仅在superview上调用layoutSubviews
  • init does not cause layoutSubviews to be called (duh)
  • addSubview causes layoutSubviews to be called on the view being added, the view it’s being added to (target view), and all the subviews of the target view
  • setFrame intelligently calls layoutSubviews on the view having it’s frame set only if the size parameter of the frame is different
  • scrolling a UIScrollView causes layoutSubviews to be called on the scrollView, and it’s superview
  • rotating a device only calls layoutSubview on the parent view (the responding viewControllers primary view)
  • removeFromSuperview – layoutSubviews is called on superview only

更多推荐

何时调用layoutSubviews方法?

本文发布于:2023-08-04 09:12:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1295005.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方法   layoutSubviews

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!