views:

485

answers:

2

I have a UISplitView-based app with a UIWebVIew in the Detail View. I want to make it change its content when user chooses a new row in the table in Root View. I tried like this in DetailViewController:

- (void)setDetailItem:(id)newDetailItem {
extern NSString *rowname;
if (detailItem != newDetailItem) {
    [detailItem release];
    detailItem = [newDetailItem retain];        
    // Update the view.
if ([rowname isEqualToString:@"About"])
 [self loadFile:@"About.rtf"];
if ([rowname isEqualToString:@"Square"])
 [self loadFile:@"Square.rtf"];
//And so on with every UITableView element from the RootView
if (popoverController != nil) {
    [popoverController dismissPopoverAnimated:YES];
}   
}
}

Help me, please! Thanks in advance!

A: 

You need a reference to the viewcontroller which contains the webview (your detail view controller) within your rootview controller. when a row is selected, call a method in the webview (detail) controller and pass it a filename, URL, whatever... and it in turn calls the uiwebview method to load the request. Either loadRequest: or loadHTMLString: docs here

wkw
I managed to do it like in the tutorials and examples on the web. But in the tutorials the UITableView has only one level and I have a two leveled table. That's the problem now
Knodel
You need a UINavigationController wrapping your tableview controller, then a table row selection (creates if needed, and...) pushes the new view controller. Just look at any sample source code where there are multiple drill-down tables. It works the same here.
wkw
+1  A: 

See the videos in chapter 3 on this website: http://www.lynda.com/home/DisplayCourse.aspx?lpk2=65722

Tiago Ribeiro