View is null in viewDidLoad

前提是你 提交于 2019-12-02 03:36:12

viewDidLoad returning a nil view if the view is connected in your .xib could mean:

For programmatic initialisation (custom controllers):

  • You forgot to call initWithNibName:bundle: on the view controller class altogether (you may have called init or something instead).
  • You've overridden the loadView method in your view controller class, but it doesn't set the view.

For all controllers:

  • An outlet connection hasn't been made correctly.
  • You have accidentally released the view or view controller before showing it.
  • The nibName parameter was not properly specified when initialising the view (the nib could not be found or one without a view was found.. though this should also throw an exception).
  • There wasn't enough memory to allocate the view (the app would likely have been terminated by that point though).

I'd recommend you try doing frame size calculations in viewWillAppear: instead and see if the view is still nil at that point.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!