私はコードの簡単なスニペットに苦労しています。私は多くの時間を探してチェックフォーラムをチェックし、さまざまなことを試しました。私はほとんどそこにいるが、それほどではない。基本的に私はUITableViewの内容をPDFに変換する必要があります。Convertir UITableView to PDF
私がすぐ下にあるコードは、ユーザーがにを持っていることを除いてうまく動作しているようですが、その部分はレンダリングされません。私はプログラムでUITableViewをスクロールしましたが、それはトリックをやっているようには見えません。あなたは私が今使っているコードを固定するための提案をお持ちの場合は持って起こるあなたのこと、これは
-(void) createPDFfromUITable:(UIView*)aView saveToDocumentsWithFileName:(NSString*)aFilename
{
CGRect priorBounds = self.tableView.bounds;
CGSize fittedSize = [self.tableView sizeThatFits:CGSizeMake(priorBounds.size.width,3000)];
self.tableView.bounds = CGRectMake(0, 0, fittedSize.width,1800);
CGRect pdfPageBounds = CGRectMake(0, 0,self.view.bounds.size.width,792);
NSMutableData *pdfData = [[NSMutableData alloc] init];
UIGraphicsBeginPDFContextToData(pdfData, pdfPageBounds, nil);
CGFloat pageOriginY=0;
for(int i=0;i<2;i++)//for (CGFloat pageOriginY = 0; pageOriginY < fittedSize.height; pageOriginY += pdfPageBounds.size.height)
{
UIGraphicsBeginPDFPageWithInfo(pdfPageBounds, nil);
CGContextSaveGState(UIGraphicsGetCurrentContext());
{
CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0, -pageOriginY);
[self.tableView.layer renderInContext:UIGraphicsGetCurrentContext()];
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:([_resultados count]-1)] atScrollPosition:UITableViewScrollPositionTop animated:NO];
CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0, -pageOriginY);
} CGContextRestoreGState(UIGraphicsGetCurrentContext());
pageOriginY += pdfPageBounds.size.height;
}
UIGraphicsEndPDFContext();
self.tableView.bounds = priorBounds; // Reset the tableView
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSString *filePathPDF = [documentsPath stringByAppendingPathComponent:aFilename];
[pdfData writeToFile:filePathPDF atomically:YES];
[self showEmail:filePathPDF];
}
:-)昨日のために固定私はQuartz2Dに、より多くの、さらにこのようなものを理解するために取得していますが、クライアントが必要すべてのことを行う全体のスニペット、これは非常に高く評価されるだろう。