2011-04-19 150 views
1

我的应用程序在contentview中有一个UITableView,而tableview的内容不在contentview中,当我使用以下代码从tableview中生成PNG文件时,只生成了可见内容。但我想要将整个tableview作为最终的PNG文件生成,怎么办?如何将UITableView的内容保存为PNG文件?

UIGraphicsBeginImageContext(self._tableView.contentSize); 
[self._tableView.layer renderInContext:UIGraphicsGetCurrentContext()]; 
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 

return UIImagePNGRepresentation(image); 

回答

0

它似乎并不可能,因为表视图的内容将仅当其- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath将被称为该indexpath。只有当tableview单元格可见时才会调用它。由于内容不可用,因此无法将其另存为PNG。

+0

感谢您的回复,我也这么认为,您是对的。 – ZYiOS 2011-04-22 04:27:23