0

我的应用程序有一个 RSS tableView,在另一个页面上有一个 WebView。我可以通过单击 RSS 中的任何项目打开 WebView 但我无法传递链接并在 WebView 中显示网站下面是我的代码

(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];

    NSString * storyLink = [[stories objectAtIndex: storyIndex] objectForKey: @"link"];


    // clean up the link - get rid of spaces, returns, and tabs...
    storyLink = [storyLink stringByReplacingOccurrencesOfString:@" " withString:@""];
    storyLink = [storyLink stringByReplacingOccurrencesOfString:@"\n" withString:@""];
    storyLink = [storyLink stringByReplacingOccurrencesOfString:@"  " withString:@""];


    [tableView deselectRowAtIndexPath:indexPath animated:NO];

    browserScreen = [[DetailsViewController alloc] initWithNibName:@"DetailsViewController" bundle:nil];
    [self.view addSubview:browserScreen.view];


    // open in Safari --> this line works perfect but I want to open the link in my own Webview so I commented it out
    //[[UIApplication sharedApplication] openURL:[NSURL URLWithString:storyLink]];

 }

谢谢你的帮助!

4

1 回答 1

0

假设 UIWebView 在您的 DetailsViewController 中,您必须在 DetailsViewController 中的 WebView 中设置 URL。

browserScreen.webView.request = [NSURLRequest requestWithURL:[NSURL URLWithString:storyLink]];
于 2012-05-11T18:17:45.807 回答