开发者

View is null in viewDidLoad

I created UITabBarController with each tab contain UINavigationController and set rootviewcontroller in this UINavigationController, all of this is done in interface builder. In viewDidLoad I try to get frame size from view, but when I reference view it return null. Have anyone experienced this before.

All IBoutlet are properly 开发者_如何学Pythonconnected.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜