self.tabBarController is NULL

女生的网名这么多〃 提交于 2019-12-06 03:37:37

In the documentation for tabBarController I see the following

If no tab bar is present or the receiver is a modal view, this property is nil.

In the comments it says that you are calling self.tabBarController from within the LoggedInFeedNavigationController and I would think it should work properly. But you are displaying the tab bar modally and if the documentation means even if it is inside of UITabBarController as a modal view then that is your problem.

It looks to me like your releasing your tab bar controller when you haven't finished with it. You want to initialize it once and release it only when your done with it like in the dealloc method.

Joe is completely right. This is also the case for custom segues as well. (Example: SWRevealViewController, etc)

This is what I did to get it to work based on Joe's answer and apples documentation. In YourTabBarViewController.h file add the following:

 @property (nonatomic, retain) UITabBarController * myTabBarController;

Then in YourTabBarViewController.m file in viewDidLoad add the following:

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