我正在使用 iOS 5 和 Storyboard。我能够在 tableView 中显示来自“ http://feeds.reuters.com/reuters/INcricketNews ”的 RSS 提要。但是我无法显示来自特定单元格的条目,在 webView 中点击时。下面是我的代码。
@interface BlogRss : NSObject //This is what i am fetching.
@property(nonatomic, copy) NSString * title;
@property(nonatomic, copy) NSString * description;
@property(nonatomic, copy) NSString * linkUrl;
@property(nonatomic, copy) NSString * guidUrl;
@property(nonatomic, retain) NSDate * pubDate;
@property(nonatomic, copy) NSString * mediaUrl;
@end
我的 TableViewController 配置为 -
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"rssItemCell"];
if(nil == cell){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"rssItemCell"];
}
cell.textLabel.text = [[[[self rssParser]rssItems]objectAtIndex:indexPath.row]title];
cell.detailTextLabel.text = [[[[self rssParser]rssItems]objectAtIndex:indexPath.row]description];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"ShowDetail" sender:self];
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"ShowDetail"])
{
ArticleDetailViewController *detailViewController = [segue destinationViewController];
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
// self.entry = [self.allEntries objectAtIndex:indexPath.row];
detailViewController.entry = [self.allEntries objectAtIndex:indexPath.row];
NSLog(@"current row contains %@ ",detailViewController.entry); //This shows null.
}
}
这是我的 WebViewController
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:YES];
self.newsView.delegate =self;
// self.entry =[[BlogRss alloc]init];
NSURL *url =[NSURL URLWithString:self.entry.linkUrl];
[self.newsView loadRequest:[NSURLRequest requestWithURL:url]];
NSLog(@"The URL is %@",url); //This shows null as well.
}