I have working on pick the photo from gallery and save in gallery
my code is
-(void)onclicksave:(id)sender
{
NSLog(@"onclicksave");
UIImagePickerController *picker=[[UIImagePickerController alloc]init];
picker.delegate=self;
if((UIButton *)sender== openLibrary)
{
picker.sourceType=UIImagePickerControllerSourceTypeSavedPhotosAlbum;
}
else
{
picker.sourceType=UIImagePickerControllerSourceTypeCamera;
}
[self presentModalViewController:picker animated:YES];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[picker dismissModalViewControllerAnimated:YES];
imagedisplay.image=[info objectForKey:@"UIImagePickerControllerOriginalImage"];
}
but in this code run time error like
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Source type 1 not available'
so give any suggestion and source code which is apply in my code
Well, this means what it says. UIImagePickerControllerSourceTypeCamera
is a value from enum, equal to 1. You're trying to run your code on simulator or on device, that doesn't have camera.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With