【发布时间】:2014-04-08 08:12:10
【问题描述】:
我有一个按钮来捕捉图片,然后保存到 photoAlbum。我使用另一个按钮从使用imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 加载图像,然后我实现didFinishPickingMediaWithInfo: 将相册加载到newImage。我需要的是在拍摄照片后我有 alertview 然后单击是按钮自动加载最后拍摄的图像 PhotoAlbum 并添加 newImage。有可能吗?
- (void)saveImageToPhotoAlbum
{
[self.library saveImage:[self stillImage] toAlbum:@"Album" withCompletionBlock:^(NSError *error) {
if (error!=nil) {
NSLog(@"Big error: %@", [error description]);
}
}];
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Gallery"
message:@"Do you want to use the captured image?" delegate:self
cancelButtonTitle:@"Cancel" otherButtonTitles:@"Yes", nil];
alertView.tag = 2;
[alertView show];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
//set image
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
newImage = [[UIImageView alloc] initWithImage:[info objectForKey:UIImagePickerControllerOriginalImage]];
[newImage setFrame:CGRectMake(0, 0, 320, 568)];
[self.view addSubView:newImage];
}
我需要将最后捕获的图像显示到 newImage 点击 alertView 按钮:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
// the user clicked one of the OK/Cancel buttons
if (buttonIndex == 1){
}
}
【问题讨论】:
标签: ios uiimage uiimagepickercontroller photo-gallery