Objective C - addobserver 用于 UIView 添加子视图?
有没有一种简单的方法可以监听子视图或子视图何时添加到 UIView 中?
我已经浏览了 addobserver 选项,但还没有找到明显的选项。当内容添加到视图时,可能还有另一个选项会受到影响,还是我说错了?即内容的宽度或高度、位置等?
编辑 使用下面@Alkimake的建议(TextHolderClass)可以轻松完成此操作。 我创建了一个自定义 UIView 子类,并将 Interface Builder 中的 UIView 类设置为等于 TextHolderClass
感谢您的帮助,我知道这应该是显而易见的:)
Is there an easy way for listening for when a child or subview has been added to a UIView?
I've gone through the addobserver options and haven't found an obvious option anyway. There may be another option that would be affected though when content is added to a view or am I wrong in saying that? i.e. content width or height, positions, etc.?
Edit
This is accomplished easily using the advice of @Alkimake below (TextHolderClass).
I created a custom UIView subclass and set the UIView's class in Interface Builder to be equal to TextHolderClass
Thanks for your help, I know it should have been obvious :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
UIView
方法可以帮助您:UIView
methods may help you:UIView 有 2 个方法在子视图交互后调用。只需创建您的自定义
UIView
类并实现这些对您来说非常有用的方法。并使用您自己的CustomView
UIView has 2 methods to call after subview interactions. Simply create your custom
UIView
class and implement these methods which is pretty for you. And use your ownCustomView