iphone - iOS截取tableview的截图

标签 iphone ios cocoa-touch ipad

所以我正在创建一个 iPad 应用程序,我需要在其中截取 tableview 的屏幕截图并稍后显示,类似于 iPad safari 选项卡页面。我需要在不实际改变方向的情况下在两个方向上截取屏幕截图。我该如何存档?

最佳答案

您所描述的内容超出了任何“屏幕截图”的范围。您将需要为表格 View 手动生成图像。如果 View 很简单(即一些文本、分隔符等),您可以使用 CoreGraphics 或类似的东西从头开始绘制图像。我维护一个名为 ANImageBitmapRep 的开源类这允许简单的像素级和上下文级图像操作。在这种情况下,您很可能会使用核心图形,但首先是如何生成上下文:

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

关于使用 CoreGraphics 绘图的小教程可以在 http://idevhub.com/exploring-iphone-graphics-part-1/ 找到。 .

关于iphone - iOS截取tableview的截图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7099740/

相关文章:

iphone - 将 xml 作为 post 发送到 Web 服务时获取响应代码 400

ios - 在不显示键盘的情况下获取iOS键盘的高度

iphone - 如何根据UI导航栏的大小设置内容大小

iphone - 整数声明和数组计数指令的问题

iphone - 正在重置 UIView 布局

ios - 更改 UITableViewCell 中 UILabel 的背景颜色

ios - 如何删除我的 NSString 中带有括号 () 的任何子字符串?

iphone - 使用 QuartzCore 在 UITableViewCell 中的 UIImageView 上圆角时滚动体验缓慢

iphone - UIGestureRecognizer 的子类仅在一个 UIImageView 上工作

ios - 如何在 Swift 中实现 Chartboost didCloseInterstitial