2

I am developing an app wherein a user action should lead to the reduction of TabController options (icons) from 5 down to 3.
I understand the code required to modify the TabController but am unable to force it to refresh (viewDidLoad) since the ViewController where the user interacts is several steps downstream from the tab controller (the flow aslo includes a NavController). As a result

self.tabBarController?.viewDidLoad()

does not seem to work.

Here is my code:

    print("pressed tab refresh")
    print(self.tabBarController)
    //this next line confirms that I can "see" the tab controller in question
    print(self.tabBarController?.title)

    //expect this to work
    self.tabBarController?.viewDidLoad()

    //trying this as well
    var setTBC = self.tabBarController
    setTBC?.delegate = self
    setTBC?.viewDidLoad()
  • did u create tabbar using storyboard or through code , you need to use delegate for it , this direct method won't work , but its very good question – Shobhakar Tiwari Dec 07 '16 at 17:35
  • `viewDidLoad` isn't something that you are supposed to call. It's there for you to set up UI elements when the UIKit calls you. – Phillip Mills Dec 07 '16 at 17:54
  • Thanks Shobhakar. I created the tab bar via storyboard. I've also tried forcing that upstream tab bar into a variable and making it it's own delegate but this produced an error. I'll update above with my code – Christopher McFadden Dec 07 '16 at 17:58
  • Thanks Phillip, I wasn't aware. Is there a better way to force a container view controller or tab controller to update while allowing the user to remain in their current ('child') controller? – Christopher McFadden Dec 07 '16 at 18:01

0 Answers0