簡體   English   中英

iOS 對tableview進行截圖

[英]iOS taking a screenshot of tableview

所以我正在創建一個 iPad 應用程序,我需要在其中截取表格視圖並稍后顯示,類似於 iPad safari 選項卡頁面。 我需要在兩個方向上截取屏幕截圖而不實際改變方向。 我怎樣才能歸檔這個?

您所描述的超出了任何“屏幕截圖”的限制。 您將需要手動生成表格視圖的圖像。 如果視圖很簡單(即一些文本、分隔符等),您可以使用 CoreGraphics 或類似的東西從頭開始繪制圖像。 我維護了一個名為ANImageBitmapRep的開源 class,它允許輕松進行像素級和上下文級圖像操作。 在這種情況下,您很可能會使用核心圖形,但首先是生成上下文的方式:

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

可以在http://idevhub.com/exploring-iphone-graphics-part-1/找到有關使用 CoreGraphics 繪圖的小教程。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM