本文介绍了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无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 01:24