Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To prevent your image this code will help you- </p> <p>Define these macros on the top of your ViewController class- </p> <pre><code> #define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) #define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) #define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) #define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending) </code></pre> <p>Then manage your delegate method in this way- </p> <pre><code>#pragma mark- Delegate methods of UIImagePickerController Class - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { UIImage *pickedImage = [info objectForKey:UIImagePickerControllerOriginalImage]; NSString *imgType = [info objectForKey:UIImagePickerControllerReferenceURL]; //NSLog(@"%@",imgType); imgType = [imgType lastPathComponent]; NSData *imageData; if (SYSTEM_VERSION_LESS_THAN(@"6.0")) { // code here imageData = UIImagePNGRepresentation(pickedImage); } if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) { // code here imageData = UIImageJPEGRepresentation(pickedImage, 0.5); } NSError * error = nil; [imageData writeToFile:path options:NSDataWritingAtomic error:&amp;error]; if (error != nil) { NSLog(@"ERROR: %@", error); return; } [picker dismissViewControllerAnimated:YES completion: nil]; } </code></pre> <p>It will capture the images according to your requirement. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload