0

UITextfield、UITextview、UIImageを含むさまざまなセルでUITableを作成しようとしています。画像やテキストを含むすべてのセルを含むレポートのようなPDFを生成したいと思います。

UITableviewcellのスクリーンショットを1つ作成するためのコードがあります。しかし、複数のスクリーンショットを作成し、それらをマージして1つのPDFファイルを作成する方法がわかりません。

以下は、UITableviewcellのスクリーンショットを作成するために持っているコードです。ありがとう

NSUInteger index[] = {0, 0}; // section, row
    NSIndexPath *indexPath = [[NSIndexPath alloc] initWithIndexes:index length:2];

    // Get the cell
    UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];

    // Render a graphics context to turn your cell into a UIImage
    CGSize imageSize = cell.bounds.size;
    UIGraphicsBeginImageContext(imageSize);
    CGContextRef imageContext = UIGraphicsGetCurrentContext();

    [cell.layer renderInContext:imageContext];



    // Retrieve the screenshot image

    UIImage *imagefinal = UIGraphicsGetImageFromCurrentImageContext();



       UIGraphicsEndImageContext();

  UIImageWriteToSavedPhotosAlbum(imagefinal, nil, nil, nil);
4

1 に答える 1

1

複数のスクリーンショットを撮る方法がわかりませんが、2つの画像をマージするためのコーディングを行ったことがあります。複数のスクリーンショットをマージするには、このコードにいくつかの変更を加える必要があります。これがコードです。

        CGSize endImageSize = CGSizeMake(0, 0);

        endImageSize =  CGSizeMake(CELL_IMAGE_WIDTH,DesiredHeight);


        UIGraphicsBeginImageContext(endImageSize);

        // draw images into this context
        [anOriginalImage1 drawInRect:CGRectMake(0, 0,
                                               endImageSize.width, IMAGE1_HEIGHT)];
        [anOriginalImage2 drawInRect:CGRectMake(0, IMAGE1_HEIGHT,
                                            endImageSize.width, IMAGE2_HEIGHT)];

        //convert context into a UIImage
        UIImage *endImage = UIGraphicsGetImageFromCurrentImageContext();

        //cleanup   
        UIGraphicsEndImageContext();
于 2013-03-09T20:12:53.503 に答える