当选择 RootView 中的一行时,如何使 UISplitView 的详细信息视图中的 UIWebView 更改其内容?
我有一个基于 UISplitView 的应用程序,在详细信息视图中有一个 UIWebVIew 。当用户在根视图中的表中选择新行时,我想让它更改其内容。我在 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];
}
}
}
请帮助我! 提前致谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅以下网站上第 3 章中的视频:http://www.lynda。 com/home/DisplayCourse.aspx?lpk2=65722
See the videos in chapter 3 on this website: http://www.lynda.com/home/DisplayCourse.aspx?lpk2=65722
您需要对视图控制器的引用,其中包含根视图控制器中的网络视图(您的详细视图控制器)。当选择一行时,调用 webview(详细信息)控制器中的方法并向其传递文件名、URL 等......然后它依次调用 uiwebview 方法来加载请求。
loadRequest:
或loadHTMLString:
此处的文档
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:
orloadHTMLString:
docs here