0

PDFを作成するためのraywenderlichチュートリアルに従いました。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];
}
4

1 に答える 1

0

に webView をロードできます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.
}

それは私のために働いています。それが役に立てば幸い

于 2013-01-26T05:11:59.213 に答える