Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPad UISplitViewController multiple root views

I am developing for iPad and have created a standard UISplitViewController application using the template provided in Xcode - a standard UITableView on the left and a detail view on the right.

I have modified the template so that when a user selects a table cell from the left view it pushes a new table view in it's place (still on the left side). This works without issue, but I would like to be able to update the existing detail view from the new table view - kinda like how Apple's Mail application works.

- I am not trying to create multiple views on the detail view (right hand side) - I've read the documentation and seen the sample code provided by Apple.

I read/followed many tutorials, but can't seem to get this relatively simple view hierarchy to work.

More detail:-

Using detailViewController.detailItem = @"Test"; in the RootView didSelectTableRowAtIndexPath delegate method updates the Detail view label. Using the exact same code in the newly pushed Table View does not update the label - am I missing a reference point or something??

Since posting I've tried to use protocols & delegates to update a label on the detail view. The label updates correctly when changed from the Root View using the new methods, however, when I push a new view onto the root view (left hand side) I can no longer update the label.

like image 438
KSoza Avatar asked Aug 26 '26 10:08

KSoza


1 Answers

At some point after creating the RootViewController (or maybe even in a custom init method) you are setting the delegate for the DetailViewController, its a common mistake that when a new rootViewController is pushed onto the NavController that you forget to set the delgate again.

You probably are creating a new controller in the:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;

method and recording/incrementing the level of the new controller before you push it onto the navController. After you create this new controller, set the delegate again.

newRootController.myDelegate = self.myDelegate;

Before you do this If you NSLog the delegate just before you use it, you will probably find its nil.

like image 164
Luke Mcneice Avatar answered Aug 28 '26 02:08

Luke Mcneice



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!