IPad UISplitViewController multiple root views

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

I changed the template so that when the user selects a table cell from the left view, he places a new table view in it (still on the left side). This works without problems, but I would like to be able to update the existing detailed view from a new view of the table - it seems like the Apple Mail application works.

- I'm not trying to create multiple views on the detailed view (right). I read the documentation and saw a sample code provided by Apple.

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

Details: -

Using the detailViewController.detailItem = @"Test";RootView didSelectTableRowAtIndexPath in the delegate method updates the Detail view label. Using the same code in a recently migrated table view does not update the label - am I missing a checkpoint or something?

After posting, I tried using the protocols and delegates to update the shortcut on the detail view. The shortcut is updated correctly if you change it from the Root View using the new methods, however, when I click on the new view in the root mode (on the left), I can no longer update the label.

+3
source share
4 answers

- RootViewController (, , ) DetailViewController, , rootViewController NavController, delgate .

, :

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

/ , navController. .

newRootController.myDelegate = self.myDelegate;

, NSLog , , , , .

+1

viewControllers UISplitViewController

@property (, ) NSArray

* viewControllers Discussion . - , . , 0 1 .

, . - popover.

+1

, detailViewController! . - :

newRootViewController.detailViewController = self.detailViewController

Otherwise, your new root view will never know about the detailView. For your new root (table) view, you need to do things like:

#import <UIKit/UIKit.h>
@class DetailViewController;

    @interface VorhersageTable : UIViewController {
        UITableView *vorhersageTableView;
        DetailViewController *detailViewController;
    }
    @property (nonatomic, retain) IBOutlet UITableView *vorhersageTableView;
    @property (nonatomic, retain) DetailViewController *detailViewController;
    @end

to declare a detailViewController property in your new class.

0
source

Add this to your RootViewController.didselectRow before clicking on the second table (e.g. SubRoot)

SubRoot *subController = [[SubRoot alloc] initWithNibName:@"SubRoot" bundle:nil];
subController.detailViewController = self.detailViewController;

And create SubRoot.h and SubRoot.m similar to RootViewController.

@class DetailViewController;
@interface SubRoot : UITableViewController {
    DetailViewController *detailViewController;
}
@property (nonatomic, retain)  DetailViewController *detailViewController;
@end

then synthesize detailViewController.

Hope this helps.

0
source

Source: https://habr.com/ru/post/1766969/


All Articles