我需要实现创建文本 pdf 的功能,其中包含具有 UITableView 控制器的视图的多个页面。
我可以创建 pdf,但只有一页。
问题是这样的:我无法在将 tableView 渲染到 pdf 上下文时破坏它。我正在使用以下代码来执行此操作:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
UIGraphicsBeginPDFContextToFile([NSString stringWithFormat:@"%@/test.pdf",documentsDirectory],CGRectMake(0, 0, m_TableView.frame.size.width, m_TableView.frame.size.height), nil);
UIGraphicsBeginPDFPage();
[self.m_TableView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIGraphicsEndPDFContext();
如您所见,我正在使用self.m_TableView.layer
渲染。我不能打破 UITableView 层。
有没有其他方法可以从 tableview 控件创建包含多个页面的 pdf?