iOS 5 と Storyboard を使用しています。「 http://feeds.reuters.com/reuters/INcricketNews 」の RSS フィードをtableView に表示できます。ただし、特定のセルのエントリを表示することはできません。 webView.Below でタップしたときは、私のコードです。
@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.
}