PDF inside a navigational app using UITableView and UIWebView
My goal is to make a navigational Table View iOS app, with each cell representing a different PDF. All PDFs will be local.
I based my Table code off of a tutorial.
RootViewController.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *selectedRoute = [listOfItems objectAtIndex:indexPath.row];
DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]];
dvController.selectedRoute = selectedRoute;
[self.navigationController pushViewController:dvController animated:YES];
[dvController release];
dvController = nil;
}
I based my UIWebView code off of this video tutorial.
DetailViewController.m
- (void)viewDidLoad {
NSString *endereco = [[NSBundle mainBundle] pathForResource:@"Clinton" ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:endereco];
NSURLRequest *urlEndereco = [NSURLRequest requestWithURL:url];
[webView loadRequest:urlEndereco];
[self.view addSubview:webView]开发者_如何学运维;
webView.scalesPageToFit = YES;
[super viewDidLoad];
self.navigationItem.title = @"Selected Route";
}
I replaced the textbox from the Table tutorial with the UIWebView, but I'm just getting a blank view when I run it. What else do I have to add to allow my pdf to appear?
your DetailViewController doesn't have the code from viewDidLoad that you have written, it just says:
- (void)viewDidLoad {
[super viewDidLoad];
//Display the selected route.
lblText.text = selectedRoute;
//Set the title of the navigation bar
self.navigationItem.title = @"Selected Route";
}
I also fixed your outlets in detail view controller, view should point to the encapsulating view, not the webView made a new outlet called webView connected to the webView.
http://ObjectivelyBetter.com/tests/SeniorProject.zip
精彩评论