我正在做一个 iPhone 应用程序,它在单击它们各自的表格单元格时加载 14 个不同的 PDF 文件。已经创建了两个 ViewController,并且一个 UIWebview 用于加载 PDF 文件。我的问题是,单击每个表格单元格时都会将我带到同一个 PDF 文件。是否可以提供我可以参考的任何参考资料或源代码?请帮忙!
#import "IssueDetailViewController.h"
#import "ItemsViewController.h"
#import "Issues.h"
#import "IssueCell.h"
@interface IssueDetailViewController ()
@end
@implementation IssueDetailViewController
@synthesize issueItem;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
-(void)viewDidLoad
{
[super viewDidLoad];
NSString *path = [[NSBundle mainBundle] pathForResource:@"network_38" ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webview loadRequest:request];
webview.autoresizingMask=(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
[webview setScalesPageToFit:YES];
}
- (void)viewDidUnload
{
IssueView = nil;
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
IssueDetailViewController *detailViewController = [[IssueDetailViewController alloc] init];
[[self navigationController] pushViewController:detailViewController animated:YES];
}
-(void) viewWIllAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
-(void) setIssueItem:(Issues *)i
{
issueItem = i;
[[self navigationItem] setTitle:[issueItem issueName]];
}
@end