0
votes

I have a tab bar controller in the master view of a split view controller. I add a subview to that tab bar controller to show some information. I don't use a modal view because I don't want modal behavior and I need that subview to show inside the master view.

The display of this information view may be triggered by any of several other view controllers, depending on what is being shown at the time. (For example, tapping a cell in a list of a disclosure button on a map.)

Occasionally, when I dismiss this information subview, the view shown by the tab bar controller is blank. It is typically solid back or white. I can switch tabs, and when I get back to the tab I was at, the view is drawn properly.

I want to try using the setNeedsDisplay method on the view, so I tried this inside my tab bar controller class:

- (void) redrawCurrentTab {
    UIView *currentView = [[self.viewControllers objectAtIndex:self.selectedIndex] view];
    [currentView setNeedsDisplay];
}

I checked that the value of currentView is correct for the view that should be shown. But the view is not being redrawn as I was hoping.

So I have two problems that I can see:

  1. I may not understand how setNeedsDisplay works.
  2. I'm looking for advice on a better way to accomplish this showing of the information view rather than as a subview of the tab bar controller.
1

1 Answers

0
votes
// This is a hack, because the current tab is disappearing when the details view is withdrawn.
// So it needs to cycle to another view and then back.
- (void) redrawCurrentTab {
    if (currentIndex == 0) 
        self.selectedIndex = 1;
    else
        self.selectedIndex = 0;
    self.selectedIndex = currentIndex;
}

currentIndex is set in the delegate method tabBarController:didSelectViewController: