0

Possible Duplicate:
Convert UIWebview contents to a UIImage when the webview is larger than the screen

UIGraphicsBeginImageContext can convert a view to an image. But if a table-view is longer than the screen, the function can't show the whole table-view.

How can I do this?

Community
  • 1
  • 1
  • I got The solution but it is funny one. I put the Table view inside a scroll view. then the height for scrollview content is equal to tableview.content.size.height. then i update the size after tableview finish load. then i disable tableview scroll features. then i convert the scrollview content to UIImage. funny solution and i not suggest to use this but... it works for now :D – Muhammad Asyraf Mar 16 '18 at 10:49
  • the height of scrollview content just put any random for start... then update it afterward – Muhammad Asyraf Mar 16 '18 at 10:50

2 Answers2

1

See this answer: https://stackoverflow.com/a/5104559/254422 Just replace the UIWebView with UITableView.

Community
  • 1
  • 1
hwaxxer
  • 3,363
  • 1
  • 22
  • 39
0

This will get an image of the whole UITableView.

UIImage *image = nil;
CGRect oldFrame = self.tableView.frame;
[self.tableView setFrame:CGRectMake(0, 0, self.tableView.contentSize.width, self.tableView.contentSize.height)];
UIGraphicsBeginImageContext(self.tableView.contentSize); {
    [self.tableView.layer renderInContext:UIGraphicsGetCurrentContext()];
    image = UIGraphicsGetImageFromCurrentImageContext();
}
UIGraphicsEndImageContext();
[self.tableView setFrame:oldFrame];
Martol1ni
  • 4,684
  • 2
  • 29
  • 39
  • thx ,i have work it out . but i got another question. then the height of the image gets longer ,the resolution of the image will get lower .thus the image is not clear ...how could i do – user1870100 Dec 02 '12 at 15:18