2

私はconcatenatingいくつかの文字列をユーバー文字列にまとめ、それを に引き寄せPDFます。しかし、不思議な理由で、弦は で時期尚早に廃止されましたline 48。文字列自体に必要な情報が適切なタイミングですべて含まれていることを確認しました。これは、問題が別の場所にあることを示しています。

何が起こっている可能性がありますか?

これは私のコードです:

@interface Review ()
{
    CGSize pagesize;
    UIDocumentInteractionController *documentInteractionController;
}

...
UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, 612, 3000), nil); 
...

// prepare string ... we're in a loop
// each addition is typically a single line and either a word or number
// as you can see the first string is itself. it's possible i'm doing this in a hacky way, but i am preparing pdfText in multiple stages identical as below in the loop and decided to use on string instead of many.
// i can post the entire loop if requested, but i don't see any additional useful information it provides as it's simply a series of the code line below
pdfText = [NSString stringWithFormat:@"\n%@\n%@\n%@\n%@\n%@\n%@\n", pdfText, _fd.t2_tripNumber[i], _fd.t2_departure[i], _fd.t2_outFuel[i], _fd.t2_startHobbs[i], _fd.t2_whoIsFlying[i]];


if(i == 0)
{
     // for reasons undetermined, i have to offset by a large negative value to format the text properly. if set to 0, the text is near the middle of the page??? i'm thinking this is a clue.
     // if pdfText is set to a single line, the negative bias is unneeded. wtf?
        rect = CGRectMake(offset, -103, pagesize.width, pagesize.height);
 }else{
        rect = CGRectMake(offset, 12, pagesize.width, pagesize.height);
 }  

 [pdfText drawInRect:rect withFont:font lineBreakMode:NSLineBreakByWordWrapping alignment:NSTextAlignmentLeft];

これは、垂直方向のオフセットに対する特別な注意事項を示す画像です (右側の列の日付情報は、左側の列の日付ラベルと一致する必要があります)。データのエントリがさらに 9 つあるはずですが、途中で切り捨てられます。フォーマットが正しい場合は明らかですが、とにかくかなり明確です。

http://i.imgur.com/zNVXxIH.jpg

そして、これが上記のコードを呼び出すコードの本体です(内部生成)

pagesize = CGSizeMake(612, 792);
NSString *fileName = @"AirShare.pdf";
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDirectory = [path objectAtIndex:0];
NSString *PDFpathWithFileName = [docDirectory stringByAppendingPathComponent:fileName];

[self generate:PDFpathWithFileName];

NSURL *URL = [NSURL fileURLWithPath:PDFpathWithFileName];
if (URL) {
    self->documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL];
    [self->documentInteractionController setDelegate:self];
    [self->documentInteractionController presentPreviewAnimated:YES];
} 
4

1 に答える 1