UIView的initWithFrame无法正常工作? [英] UIView's initWithFrame not working?

查看:183
本文介绍了UIView的initWithFrame无法正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过Interfacebuilder将我的视图控制器设置为特定视图。
但initWithFrame没有调用,但是当我设置断点时会调用drawRect吗?

i set my view controller to the particular view through Interfacebuilder. but initWithFrame is not calling , but drawRect is being called?when i put break point?

推荐答案

对,因为在取消归档xib时,不能保证 initWithFrame:将被调用。尝试使用 awakeFromNib viewWillLoad viewDidLoad 。您选择哪一个主要取决于您在显示过程中需要插入代码的阶段。

Right, because it's not guaranteed that initWithFrame: will be called when unarchiving the xib. Try using awakeFromNib or viewWillLoad or viewDidLoad. Which one you choose will mainly depend on at what stage during the display process you need to insert your code.

另外,请查看这个问题

这篇关于UIView的initWithFrame无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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