拍照并将其保存到相册中

时间:2011-05-23 22:25:19

标签: iphone objective-c

我使用此代码拍照:

-(IBAction) getPhoto:(id) sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;

if((UIButton *) sender == choosePhotoBtn) {
    picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
} else {
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}

[self presentModalViewController:picker animated:YES];

}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [picker dismissModalViewControllerAnimated:YES];
    imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
}

我想知道如何将这张照片保存到相册中。

1 个答案:

答案 0 :(得分:1)

结帐UIKit Function Reference,使用:

UIImageWriteToSavedPhotosAlbum()

用法:

UIImageWriteToSavedPhotosAlbum(theImage, nil, nil, nil);