0

while porting our latest iPhone App to an universal app, I decided to use a iPad's SplitView Controller inside of a TabBarController. The SplitViewController is managed by AppDelegate for every Tab.

All works fine, but my problem is that my MasterView (on the left of the SplitView) includes 4 Category-Buttons to change the TableViews Data. If I click one of the buttons, the TableView needs to Refresh/ReloadData, to Display the new Content of the selected category. I created a function to do the changes and linked my buttons to it in the interface builder.

At the end of my function, I tried to refresh the Controller like this:

[self tableView ReloadData];

but the SplitView don't show the refresh. Still the old Data. I tested around a bit with NSLog, to check if my function works correctly. No problems.

Then I tried to access the tableView through SplitViewController itself, like this:

   // PresetController is my TableViewController in the SplitView  
    UISplitViewController *split = (UISplitViewController *)self.parentViewController;    
    PresetController *detail = [split.viewControllers objectAtIndex:0];   

    [detail.tableView reloadData];

Again, no error,.. but no refresh.

Am I missing something? Is there any way to easily reload the TableViewController in SplitView? I've read something about sending a Notfication via NotificationCenter to the delegate, but still couldn't find a helpful ressource.

EDIT:

For understanding my structure, here is the way I set up the SplitView in my AppDelegates "didFinishLaunchingWithOptions" Method:

NSMutableArray *controllers = [NSMutableArray arrayWithCapacity:[self.rootController.viewControllers count]];

        int tabNum = 0;
        for (UIViewController *controller in self.rootController.viewControllers) {



                UISplitViewController *split = [[[UISplitViewController alloc] init] autorelease];
                split.tabBarItem = controller.tabBarItem;
                iPadDetailView *detail = [[iPadDetailView alloc] initWithNibName:@"iPadDetailView" bundle:nil]; // a detail view will come here
                UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:detail] autorelease];

                split.viewControllers = [NSArray arrayWithObjects:controller, nav, nil];


                [controllers addObject:split];
            }
            tabNum++;
DevZarak
  • 269
  • 1
  • 5
  • 20

1 Answers1

0

Try:

PresetController *detail = [split.viewControllers lastObject];

The view controller at index 0 will be your "master" controller, and I presume that the "detail" controller is the one that has the table view you are trying to update.

Edit:

You don't want to use a UISplitViewController inside a tab view; it needs to be the rootViewController.

Paul Lynch
  • 19,769
  • 4
  • 37
  • 41
  • Hey Paul, thx for your answer. I tried it this way, getting this error: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationController tableView]: unrecognized selector sent to instance 0x8abdc20'. Seems that I only get the Navigation Controller, but not the MasterView, where my TableView is in. – DevZarak Nov 09 '11 at 14:25
  • If you have a navigation controller, then you can ask it for its view controllers (topViewController). – Paul Lynch Nov 09 '11 at 15:37
  • If I ask for the view controller, I'm getting a UILayoutContainerView. I edited my first post, showing you how I set up the SplitView in AppDelegate. – DevZarak Nov 09 '11 at 16:15
  • Sure, check the viewControllers of your navigation controller in debug; is it possible that it is using a UILayoutContainerView (which doesn't sound like a view controller) because your setting of rootViewController didn't work? – Paul Lynch Nov 10 '11 at 15:31
  • Seems that in the View of my selected tab, I have the UILayoutContainerView, which holds the PresetController (Left side) and a Navigationcontroller (right side) – DevZarak Nov 10 '11 at 15:51