I am using the following code to capture the UIView as image
-(void)startSnapSot {
NSLog(@"TakeSnapShot");
UIImage* image = nil;
// image = [self screenshot];
UIGraphicsBeginImageContext(overlayView.frame.size);
{
[overlayView.layer renderInContext: UIGraphicsGetCurrentContext()];
image = UIGraphicsGetImageFromCurrentImageContext();
}
UIGraphicsEndImageContext();
ALAssetsLibraryWriteImageCompletionBlock completionBlock = ^(NSURL *assetURL, NSError *error) {
if (error) {
NSLog(@"Error Saving Image");
}
else {
NSLog(@"Image Saved");
}
};
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeImageToSavedPhotosAlbum:[image CGImage]
orientation:(ALAssetOrientation)[image imageOrientation]
completionBlock:completionBlock];
}
But the problem is that it is saving the first image again and again i.e. it is saving same image over again and again rather than capturing different UIIView image.Could anybody let me know what wrong am I doing?