Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadView方法了解吗? #128

Open
tbfungeek opened this issue Feb 19, 2020 · 0 comments
Open

loadView方法了解吗? #128

tbfungeek opened this issue Feb 19, 2020 · 0 comments

Comments

@tbfungeek
Copy link
Owner

tbfungeek commented Feb 19, 2020

  • ViewController的rootView 是通过懒加载的方式创建的,也就是说当我们新创建一个ViewController,但是尚未调用的view的时候,这时候这个ViewController是还没有创建view的。每次调用控制器的view属性时如果发现view为nil时,loadView函数就会被调用.

  • [super loadView]默认的逻辑:如果控制器由xib或storyboard初始化,那么会根据xib或storyboard的传入的名字来初始化view;如果没有显示的指定名称,就默认加载和控制器同名的文件;如果没有找到文件,就会创建一个空白的UIView,这个view的frame为屏幕的大小。所以在覆写该方法的时候不应该再调用父类的该方法。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant