通过电子邮件发送iPhone应用的全屏 [英] Emailing full screen of iPhone app

查看:111
本文介绍了通过电子邮件发送iPhone应用的全屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个iPhone应用程序来创建使用内置图形和用户自定义文本的图像。



我想要拥有内置图形的应用程序和用户定义的文本,然后可以将其作为单个图像(非常像屏幕截图)发送到要发送电子邮件的电子邮件应用程序。



有没有办法做这个没有截图,离开应用程序,进入照片应用程序,选择屏幕截图,并从那里发送电子邮件? >

最终,我希望能够在我的应用程序中有一个按钮,用户可以点击,整个屏幕将被捕获并直接发送到邮件应用程序。



感谢任何指针!

解决方案

为了扩大布伦特的答案,以下代码将抓取一个屏幕截图,并将其保存到Documents目录中,作为一个名为screenshot.png的PNG:

  UIWindow * screenWindow = [ [UIApplication sharedApplication] keyWindow]; 

UIGraphicsBeginImageContext(screenWindow.frame.size);
[screenWindow.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

NSData * screenshotPNG = UIImagePNGRepresentation(截图);

NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString * documentsDirectory = [paths objectAtIndex:0];

NSError * error = nil;
[screenshotPNG writeToFile:[documentsDirectory stringByAppendingPathComponent:@screenshot.png]选项:NSAtomicWrite错误:& error];

这有点粗糙,因为它会在屏幕顶部附近留下一个空白点标题栏,似乎没有从CAEAGLLayers中获取内容。



此外,我不相信你可以使用标准的mailto:// URL构造,跟随通过openURL,发送MIME编码的附件。也许3.0 SDK修复了这个问题,但我还没有玩过。您可能需要使用 sksmtpmessage 等内容直接从您的应用程序中发送消息。


I am developing an iPhone app for creating images using built in graphics and user defined text.

I want to be able to have my app, with built in graphics and user defined text, which can then be sent as a single image (much like a screenshot) to the email app to be emailed.

Is there a way to do this without taking a screenshot, leaving the app, going into the Photos app, selecting the screenshot, and emailing it from there?

Ultimately I would like to be able to have a button in my app that the user could tap, and the whole screen would be captured and sent directly to the mail app.

Any pointers gratefully accepted!

解决方案

To expand upon Brent's answer, the following code will grab a screenshot and save it out to the Documents directory as a PNG called screenshot.png:

UIWindow *screenWindow = [[UIApplication sharedApplication] keyWindow];

UIGraphicsBeginImageContext(screenWindow.frame.size);
[screenWindow.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

NSData *screenshotPNG = UIImagePNGRepresentation(screenshot);

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

NSError *error = nil;
[screenshotPNG writeToFile:[documentsDirectory stringByAppendingPathComponent:@"screenshot.png"] options:NSAtomicWrite error:&error];

This is a little crude, as it will leave a blank spot near the top of the screen for the title bar, and doesn't appear to grab the content from CAEAGLLayers.

Also, I don't believe you can use the standard mailto:// URL construction, followed by openURL, to send MIME-encoded attachments. Maybe the 3.0 SDK fixes this, but I've yet to play with it. You may need to use something like sksmtpmessage to send the message directly from within your application.

这篇关于通过电子邮件发送iPhone应用的全屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆