Iphone 抓屏帮助

Iphone 抓屏帮助,iphone,iphone-sdk-3.0,Iphone,Iphone Sdk 3.0,我想在横向模式下截图 目前,我下面的代码在纵向模式下截图 另外,我想将图像存储到给定位置,而不是照片库中 我怎样才能做到这一点 谢谢你的帮助 下面是我的代码 UIGraphicsBeginImageContext(self.view.bounds.size) ; [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentIma

我想在横向模式下截图

目前,我下面的代码在纵向模式下截图

另外,我想将图像存储到给定位置,而不是照片库中

我怎样才能做到这一点

谢谢你的帮助

下面是我的代码

UIGraphicsBeginImageContext(self.view.bounds.size) ;
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, self, nil, nil); 

据我所知,没有办法在横向模式下截图。iPhone拍摄的图像包含一个名为imageOrientation的信息,该信息用于旋转显示该图像的UIImageView

但您应该能够在纵向模式下拍摄图像,并在保存之前将其旋转90度。我现在无法尝试,但以下方法应该可以奏效:

创建旋转方法并将UIImage作为参数传递

CGSize size =  sizeOfImage;
 UIGraphicsBeginImageContext(size);

 CGContextRotateCTM(ctx, angleInRadians); // (M_PI/2) or (3M_PI/2) depending on left/right rotation

 CGContextDrawImage(UIGraphicsGetCurrentContext(),
  CGRectMake(0,0,size.width, size.height),
  image);

 UIImage *copy = UIGraphicsGetImageFromCurrentImageContext();

 UIGraphicsEndImageContext();

 return copy;
要将数据存储到给定位置,您可以使用NSData,正如我在您的另一个问题()上所回答的那样