0
我想從相機或已經保存的圖像保存到iphone照片庫的圖像。 在這裏,我實現了一個代碼,但我不能在按鈕上實現它,而且它的崩潰。 我對iphone編程方面很新穎。請給一些幫助。圖像保存按鈕點擊
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info:(id)sender{
UIImage *selectedImage;
NSURL *mediaUrl;
mediaUrl = (NSURL *)[info valueForKey:UIImagePickerControllerMediaURL];
if (mediaUrl == nil)
{
selectedImage = (UIImage *) [info valueForKey:UIImagePickerControllerEditedImage];
if (selectedImage == nil)
{
selectedImage = (UIImage *) [info valueForKey:UIImagePickerControllerOriginalImage];
NSLog(@"Original image picked.");
}
else
{
NSLog(@"Edited image picked.");
}
}
else
{
NSLog(@"Video picked. Not yet implemented.");
}
[picker dismissModalViewControllerAnimated:YES];
imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
if((UIButton *) sender == savePhotoBtn) {
UIImageWriteToSavedPhotosAlbum(selectedImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}
}