iphone / ipad应用程序 - 拍摄屏幕截图 [英] iphone/ipad application - taking screen shot

查看:142
本文介绍了iphone / ipad应用程序 - 拍摄屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成功实现了一个适用于ipad和iphone的应用程序。
我提供了选项,用户可以将应用程序的屏幕截图作为邮件附件发送。即使这样运作良好。
但是无论方向如何,我的代码都会进行屏幕截图。我得到的图像始终处于纵向模式。
我想根据ipad / iphone的方向拍摄屏幕截图并将图像作为附件发送。我正在使用以下代码进行截屏。

I successfully implemented an application that works on ipad as well as on iphone. In that I provided option to user to send the screen shot of the application as mail attachment. Even that is functioning well. But my code is taking screen shot irrespective of orientation. The image i'm getting is always in portrait mode. I want to take the screen shot depending on the orientation of ipad/iphone and send the image as attachment. I'm using following code to take the screen shot.

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


推荐答案

有一个类别由Hardy Macia实施:

There is a category implemented by Hardy Macia at:

http ://www.catamount.com/forums/viewtopic.php?f = 21& t = 967

它在UIImage上有很多类别。
你想要使用的是:

It has a bunch of categories on UIImage. The one you want to be using is:

UIimage* newImage = [imageToBeRotated imageRotatedByDegrees:90.0];

您的角度取决于您设备的当前方向。
使用:

Your angle will depend on the current orientation of your device. Use:

[[UIApplication sharedApplication] statusBarOrientation]

获取设备的方向。

希望这会有所帮助。

这篇关于iphone / ipad应用程序 - 拍摄屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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