我按照raywenderlich教程创建了一个PDF。 http://www.raywenderlich.com/6818/how-to-create-a-pdf-with-quartz-2d-in-ios-5-tutorial-part-2。我需要顶部的NavBar和底部的Tab。我在底部获得了标签,但顶部缺少NavBar。 PDF正在接管底部标签栏顶部的所有内容。非常感谢任何帮助。
- (void)viewDidLoad
{
NSString* fileName = [self getPDFFileName];
NSMutableDictionary *dataDict = [NSMutableDictionary new];
NSNumber *tripId = (NSNumber *)[Helper getValueForKeyFromGlobalDictionary:TRIP_ID];
[dataDict setValue:[self retrieveTimings:[tripId intValue]] forKey:NEWTRIP_MO];
[dataDict setValue:[self retrieveStops:[tripId intValue]] forKey:TIME_MO];
[dataDict setValue:[self getCompanyInfo:[tripId intValue]] forKey:COMPANY_MO];
[dataDict setValue:[self getTripInfo:[tripId intValue]] forKey:TRIP_MO];
[dataDict setValue:[self getDriverInfo:[tripId intValue]] forKey:DRIVERS_MO];
[dataDict setValue:[self getLoadInfo:[tripId intValue]] forKey:LOAD_MO];
[PDFRenderer drawPDF:fileName withData:dataDict];
[self showPDFFile];
[super viewDidLoad];
NSLog(@"Testing");
}
-(void)showPDFFile
{
NSString* fileName = @"Invoice.PDF";
NSArray *arrayPaths =
NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory,
NSUserDomainMask,
YES);
NSString *path = [arrayPaths objectAtIndex:0];
NSString* pdfFileName = [path stringByAppendingPathComponent:fileName];
UIWebView* webView = //[[UIWebView alloc] initWithFrame:view2.frame];
[[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
NSURL *url = [NSURL fileURLWithPath:pdfFileName];
NSError *error = [[NSError alloc] init];
NSLog(@"Is resource reachable: %d", [url checkResourceIsReachableAndReturnError:&error]);
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView setScalesPageToFit:YES];
[webView loadRequest:request];
[self.view addSubview:webView];
//[self.view insertSubview:webView atIndex:3];
}
答案 0 :(得分:0)
您可以在ViewDidLoad
。
- (void)viewDidLoad
{
[super viewDidLoad];
NSString* pdfFileName = [self getPDFFileName];
NSMutableDictionary *dataDict = [NSMutableDictionary new];
NSNumber *tripId = (NSNumber *)[Helper getValueForKeyFromGlobalDictionary:TRIP_ID];
[dataDict setValue:[self retrieveTimings:[tripId intValue]] forKey:NEWTRIP_MO];
[dataDict setValue:[self retrieveStops:[tripId intValue]] forKey:TIME_MO];
[dataDict setValue:[self getCompanyInfo:[tripId intValue]] forKey:COMPANY_MO];
[dataDict setValue:[self getTripInfo:[tripId intValue]] forKey:TRIP_MO];
[dataDict setValue:[self getDriverInfo:[tripId intValue]] forKey:DRIVERS_MO];
[dataDict setValue:[self getLoadInfo:[tripId intValue]] forKey:LOAD_MO];
[PDFRenderer drawPDF:pdfFileName withData:dataDict];
UIWebView* webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 40, 320, 440)];
NSURL *url = [NSURL fileURLWithPath:pdfFileName];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView setScalesPageToFit:YES];
[webView loadRequest:request];
[self.view addSubview:webView];
self.navigationController.navigationBarHidden=NO;
// Do any additional setup after loading the view from its nib.
}
它为我工作。希望它有助于