Self.tabBarController - NULL

I created a UITabBarController as shown below and clicked on navigationController, but now I cannot set the title of the tab items, etc ... because the controller is tabbarNULL.

Please tell me where I am going wrong.

UITabBarController *tabBarController = [[UITabBarController alloc] init]; LoggedInFeedNavigationController *lvc = [[LoggedInFeedNavigationController alloc] initWithAccount:account]; [tabBarController setViewControllers:[NSArray arrayWithObject:lvc]]; [tabBarController setSelectedIndex:0]; [self presentModalViewController:tabBarController animated:YES]; [tabBarController release]; [lvc release]; 
+2
source share
3 answers

In the documentation for tabBarController, I see the following

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

The comments say that you are calling self.tabBarController from the LoggedInFeedNavigationController , and I think it should work correctly. But you show the tab bar differently, and if the documentation means that even if it is inside the UITabBarController as a modal view, this is your problem.

+6
source

It seems to me that you are releasing your tab bar controller when you are not done with it yet. You want to initialize it once and release it only when you are done with it, as in the dealloc method.

0
source

Joe is absolutely right. This also applies to user segments. (Example: SWRevealViewController, etc.)

This is what I did to make it work based on the documentation of Joe and the apples. In your YourTabBarViewController.h file, add the following:

  @property (nonatomic, retain) UITabBarController * myTabBarController; 

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

 self.myTabBarController = self; self.myTabBarController.delegate = self; 
0
source

Source: https://habr.com/ru/post/1233552/


All Articles