-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. 如果上傳格式有效,按下表單提交按鈕
- 3. 點擊按鈕時,以PDF格式下載jsp表格
- 4. 提交嵌套表格按鈕提交外在形式在IE7
- 5. Scrapy - 用多個按鈕提交表格
- 6. 表格上的多個提交按鈕
- 7. 按下按鈕時提交表單值
- 8. 隱藏提交按鈕發送表格後加載方法
- 9. 提交按鈕在表格的中間
- 10. 提交按鈕在表格數據下呈現。我只需要一個表單提交按鈕
- 11. 臉書連接按鈕提交表格
- 12. 獲取iPhone GO按鈕提交表格
- 13. 缺少PHP提交按鈕表格
- 14. 的Javascript聯絡表格提交按鈕
- 15. 如何防止按鈕提交表格
- 16. jQuery提交按鈕隱藏表格
- 17. phonegap android GO按鈕不提交表格
- 18. Symfony表格:避免提交按鈕
- 19. HTML按鈕不要提交表格
- 20. jQuery的 - 提交表格按鈕
- 21. 當我按下輸入問題時提交,HTML表格
- 22. 如何用表格發送按鈕值
- 23. 發送電子郵件和下載PDF聯繫表單7提交按鈕
- 24. 用提交按鈕的形式提交表單與幾個提交按鈕
- 25. 按鍵提交表格
- 26. 按下「Enter」按鈕提交表單?
- 27. HTML:摺疊按鈕充當表單的形式提交按鈕
- 28. 當複選框是票時發送POST - 無需提交按鈕
- 29. 按Enter鍵時提交表格
- 30. 當按下電源按鈕時在後臺發送短信
這個問題太模糊和廣泛。請縮小特定問題的範圍並澄清您的問題。 – rmaddy 2013-05-02 04:24:54