-3
A
回答
3
-(IBAction)takeScreenShot
{
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreen mainScreen].scale);
else
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIImageView *newImage = [[UIImageView alloc] initWithImage:image];
UIGraphicsEndImageContext();
[self createPDFfromUIView:newImage saveToDocumentsWithFileName:@"SecondScreen1.pdf"];
}
-(void)createPDFfromUIView:(UIImageView*)aView saveToDocumentsWithFileName:(NSString*)aFilename
{
// Creates a mutable data object for updating with binary data, like a byte array
NSMutableData *pdfData = [NSMutableData data];
// Points the pdf converter to the mutable data object and to the UIView to be converted
UIGraphicsBeginPDFContextToData(pdfData, aView.view.bounds, nil);
UIGraphicsBeginPDFPage();
// draws rect to the view and thus this is captured by UIGraphicsBeginPDFContextToData
[aView.layer renderInContext:UIGraphicsGetCurrentContext()];
// remove PDF rendering context
UIGraphicsEndPDFContext();
// Retrieves the document directories from the iOS device
NSArray* documentDirectories = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);
NSString* documentDirectory = [documentDirectories objectAtIndex:0];
NSString* documentDirectoryFilename = [documentDirectory stringByAppendingPathComponent:aFilename];
// instructs the mutable data object to write its context to a file on disk
[pdfData writeToFile:documentDirectoryFilename atomically:YES];
NSLog(@"documentDirectoryFileName: %@",documentDirectoryFilename);
}
這將是工作。
相關問題
- 1. 當按下提交按鈕時顯示錶格
- 2. HTML按鈕提交表格
- 3. 提交按鈕的下拉表格
- 4. 表格,發佈和提交按鈕
- 5. 如果上傳格式有效,按下表單提交按鈕
- 6. 點擊按鈕時,以PDF格式下載jsp表格
- 7. 用多個按鈕提交表格
- 8. Scrapy - 用多個按鈕提交表格
- 9. 表格上的多個提交按鈕
- 10. 按下按鈕時提交表單值
- 11. 隱藏提交按鈕發送表格後加載方法
- 12. 提交按鈕在表格的中間
- 13. 按下提交按鈕時發送電子郵件
- 14. 禁用單擊表格或提交按鈕時提交表單
- 15. PHP按下提交按鈕後如何讓表格消失
- 16. 用提交按鈕發送表單
- 17. 在表格單元格內放置一個提交按鈕
- 18. 當點擊瀏覽器後退按鈕時提交表格
- 19. 提交按鈕在表格數據下呈現。我只需要一個表單提交按鈕
- 20. 當按下「Enter」按鈕時,表單不會提交
- 21. 當我按下輸入問題時提交,HTML表格
- 22. phonegap android GO按鈕不提交表格
- 23. jQuery的 - 提交表格按鈕
- 24. 獲取iPhone GO按鈕提交表格
- 25. 缺少PHP提交按鈕表格
- 26. 如何防止按鈕提交表格
- 27. 使用特定按鈕提交表格
- 28. 臉書連接按鈕提交表格
- 29. Vue - 點擊按鈕提交表格
- 30. Symfony表格:避免提交按鈕
這個問題太模糊和廣泛。請縮小特定問題的範圍並澄清您的問題。 – rmaddy 2013-05-02 04:24:54