我在相机叠加层上有一系列图像。当我单击按钮时,我需要使用相机视图拍摄一张叠加图像的快照。但是当我在设备中启动时出现以下错误。我搜索了一些我无法得到答案的现有代码。
错误:
[UIImage length]: unrecognized selector sent to instance 0x1d53b6b0 2013-04-02 11:27:18.748
ARimage[1166:907] *** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[UIImage length]: unrecognized selector sent to instance 0x1d53b6b0'
数组叠加图像的代码:
NSArray *arrayOfImageFiles=[[NSArray alloc]initWithObjects:[UIImage imageNamed:@"img1.png"],
[UIImage imageNamed:@"img2.png"],
[UIImage imageNamed:@"img3.png"],
[UIImage imageNamed:@"img4.png"],
[UIImage imageNamed:@"img5.png"], nil];//array of images.
for(NSString * imageFileName in arrayOfImageFiles)//here you are getting string format but imageFileName is an image object
{
UIImage * overlay = [UIImage imageNamed: imageFileName];//here imageFileName is image simply give here UIImage * overlay=imageFileName;
if(overlay)
{
CGSize overlaySize = [overlay size];
[overlay drawInRect:CGRectMake(30 * xScaleFactor, 100 * yScaleFactor, overlaySize.width * xScaleFactor, overlaySize.height * yScaleFactor)];
} else {
NSLog( @"could not find an image named %@", imageFileName);
}
}
UIImage *combinedImage = UIGraphicsGetImageFromCurrentImageContext();
[self setStillImage:combinedImage];
UIGraphicsEndImageContext();
[[NSNotificationCenter defaultCenter] postNotificationName:kImageCapturedSuccessfully object:nil];
}];
}
捕获按钮单击的叠加图像:
- (void)ButtonPressed {
[self captureStillImageWithOverlay:[NSArray arrayWithObjects:[UIImage imageNamed:@"img1.png"],
[UIImage imageNamed:@"img2.png"],
[UIImage imageNamed:@"img3.png"],
[UIImage imageNamed:@"img4.png"],
[UIImage imageNamed:@"img5.png"], nil]];
}
图像显示在相机叠加视图中。当我单击按钮捕获叠加图像时,出现错误。