可惜没有人能够回答......如果其他人正在寻找如何做到这一点,请将didSelectRowAtIndexPath的内容更改为
if (_webViewController == nil) {
self.webViewController = [[[WebViewController alloc] initWithNibName:@"WebViewController" bundle:[NSBundle mainBundle]] autorelease];
}
MWFeedItem *entry = [parsedItems objectAtIndex:indexPath.row];
_webViewController.entry = entry;
[self.navigationController pushViewController:_webViewController animated:YES];
// Deselect
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
添加一个WebViewController;.m 有
#import "WebViewController.h"
#import "MWFeedItem.h"
@implementation WebViewController
@synthesize webView = _webView;
@synthesize entry = _entry;
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (void)viewWillAppear:(BOOL)animated {
NSURL *url = [NSURL URLWithString:_entry.link];
[_webView loadRequest:[NSURLRequest requestWithURL:url]];
}
- (void)viewWillDisappear:(BOOL)animated {
[_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc. that aren't in use.
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[_entry release];
_entry = nil;
[_webView release];
_webView = nil;
[super dealloc];
}
.h 有
@class MWFeedItem;
@interface WebViewController : UIViewController {
UIWebView *_webView;
MWFeedItem *_entry;
}
@property (retain) IBOutlet UIWebView *webView;
@property (retain) MWFeedItem *entry;
(基本上我只是把 Ray Wenderlich 的 RSS feeder 的 webview 部分放到了这个里面。)