Ios6 图像捕获中的应用程序崩溃
我正在应用程序中捕获图像,我的应用程序收到内存警告,应用程序崩溃 下面是我使用的代码。。。请帮忙。 此应用程序类似于从gallery中拾取图像并向其添加动画。当动画运行时,将捕获图像并使其成为视频 我在拍摄动画图像时收到内存警告Ios6 图像捕获中的应用程序崩溃,ios6,xcode5,image-capture,Ios6,Xcode5,Image Capture,我正在应用程序中捕获图像,我的应用程序收到内存警告,应用程序崩溃 下面是我使用的代码。。。请帮忙。 此应用程序类似于从gallery中拾取图像并向其添加动画。当动画运行时,将捕获图像并使其成为视频 我在拍摄动画图像时收到内存警告 -(void)captureImage:(NSTimer*) t { NSLog(@"captureImage"); // Create a graphics context with the target size // On iOS 4 and later, u
-(void)captureImage:(NSTimer*) t {
NSLog(@"captureImage");
// Create a graphics context with the target size
// On iOS 4 and later, use UIGraphicsBeginImageContextWithOptions to take the scale into consideration
// On iOS prior to 4, fall back to use UIGraphicsBeginImageContext
CGSize imageSize = CGSizeZero;
UIInterfaceOrientation orientation =
[UIApplication sharedApplication].statusBarOrientation;
if (UIInterfaceOrientationIsPortrait(orientation)) {
imageSize = [UIScreen mainScreen].bounds.size;
NSLog(@"imageSize:%@ ",NSStringFromCGSize(imageSize));
} else {
imageSize =
CGSizeMake([UIScreen mainScreen].bounds.size.height,
[UIScreen mainScreen].bounds.size.width);
//CGSizeMake(animatedImgView.frame.size.width, animatedImgView.frame.size.height);//
}
UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
for (UIWindow *window in [[UIApplication sharedApplication] windows]) {
CGContextSaveGState(context);
CGContextTranslateCTM(context, window.center.x, window.center.y);
CGContextConcatCTM(context, window.transform);
CGContextTranslateCTM(context,
-window.bounds.size.width * window.layer.anchorPoint.x,
-window.bounds.size.height * window.layer.anchorPoint.y);
if (orientation == UIInterfaceOrientationLandscapeLeft) {
CGContextRotateCTM(context, M_PI_2);
CGContextTranslateCTM(context, 0, -imageSize.width);
} else if (orientation == UIInterfaceOrientationLandscapeRight) {
CGContextRotateCTM(context, -M_PI_2);
CGContextTranslateCTM(context, -imageSize.height, 0);
} else if (orientation == UIInterfaceOrientationPortraitUpsideDown) {
CGContextRotateCTM(context, M_PI);
CGContextTranslateCTM(context, -imageSize.width, -imageSize.height);
}
if
([window
respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)]) {
[window drawViewHierarchyInRect:window.bounds afterScreenUpdates:NO];
//[animatedImgView drawViewHierarchyInRect:window.bounds afterScreenUpdates:NO];
} else {
//[window.layer.presentationLayer renderInContext:context];
}
CGContextRestoreGState(context);
}
// @autoreleasepool {
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[savedImages addObject:image];
image = nil;
// }
}
谢谢你的帮助 我认为将图像设置为零是不够的。见: 出现异常的另一个原因可能是内存中的图像太多。它们存放在哪里?文件系统?数据库记忆