【问题标题】:RSS link to open in WebView(iOS)在 WebView(iOS) 中打开的 RSS 链接
【发布时间】:2023-03-31 06:28:01
【问题描述】:

我的应用有一个 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]];

 }

感谢您的帮助!

【问题讨论】:

    标签: ios uitableview rss webview nsstring


    【解决方案1】:

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

    browserScreen.webView.request = [NSURLRequest requestWithURL:[NSURL URLWithString:storyLink]];
    

    【讨论】:

    • 谢谢,但这不起作用,我的问题是使用 storyLink 作为全局字符串。 webView 在 DetailsViewController 中看不到 storyLink
    • 我找到了另一个解决方案,我需要的是使用一个全局字符串将“storyLink”传递给 webView。不过,非常感谢您抽出宝贵时间
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-30
    • 1970-01-01
    • 1970-01-01
    • 2018-11-03
    • 2012-05-08
    • 2016-03-19
    相关资源
    最近更新 更多