开发者

iOS taking a screenshot of tableview

So I am creating an iPad app where I need to take a screenshot of a tableview and display it later, similar to iPad safari tabs page. I need to ta开发者_C百科ke the screenshot in both orientations without actually changing the orientation. How can I archieve this?


What you are describing is beyond the limits of any "screenshot." You will need to manually generate the images for the table view. If the view is simple (i.e. some text, separators, etc), you could do this using CoreGraphics or something of the sort to draw the image from scratch. I maintain an open source class called ANImageBitmapRep which allows for easy pixel-level, and context level image manipulation. In this case, you will most likely be using core graphics, but here's how you would generate a context in the first place:

ANImageBitmapRep * irep = [[ANImageBitmapRep alloc] initWithSize:BMPointMake(myWidth, myHeight)];
CGContextRef context = [irep context];
// ...
// use context here to manually generate your "screenshot."
// ...
[irep setNeedsUpdate]; // tell the image bitmap rep to update its image
UIImage * savedImage = [irep image]; // get a UIImage for storing
[irep release]; // free the memory

A small tutorial on drawing with CoreGraphics can be found at http://idevhub.com/exploring-iphone-graphics-part-1/.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜