-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