【发布时间】: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