1

I have a tabbed iOS 5 app where I need to keep showing a certain subview when some of the tabs are tapped and become displayed. In the following mockups I try to explain what I need: most of the tabs should keep showing a same subview that is intended to show the status of something concerning the core functionality of the app, whereas there's no need to show such status indicator subview within some of the tabs (for example, a settings tab):

iPhone_tab1 iPhone_tab2iPhone_tab3

Some of the tabs may also allow to navigate through a hierarchy of views, but the subview must keep visible even if user navigates. How could I manage this scenario? Should I create a separated .nib and UIViewController for the subview, and add/remove it as a subview of the root UITabBarController? Or should I load the .nib from within each tab bar view controller, and handle the subview within the tab's view controller? Or is there another and better way to handle this situation?

Thanks in advance

AppsDev
  • 12,319
  • 23
  • 93
  • 186
  • Keep the subview at appdelegate level and add it as `UIWindow`'s subview. Hide/Unhide based on selected tab index. Create delegate of the subview and assign the selected tab controller's view controller instance for event delegation. – Amar Jun 24 '13 at 10:16
  • @Amar You meant, defining a `@protocol` within the appDelegate and assign its delegate to be the current selected tab's view controller? – AppsDev Jun 27 '13 at 14:42
  • Define `@protocol` in the the subview, create and assign the delegate `@property` as the current selected tab's view controller. This will allow the selected tab's view controller to respond to the subview events. – Amar Jun 28 '13 at 06:13
  • @Amar Thanks. I'm not able to load the subview in the appDelegate, I'm doing this: `NSArray* views = [[NSBundle mainBundle] loadNibNamed:@"SubviewViewController" owner:nil options:nil];` and I get an empty `NSArray`, so I'm not able to add the subview to the `UIWindow`... how should I load the subview? – AppsDev Jun 28 '13 at 06:28

1 Answers1

0

Separate the subview class and its data model. The subview should listen to changes in the data model and possibly modify the data model. Each tab keeps its own subview, but since all subviews share the same data model, when you update one, you update all.

Khanh Nguyen
  • 11,112
  • 10
  • 52
  • 65