================
项目来自于苹果官方文档中的一个范例。
针对这个范例,我对一些英文注释做了中文说明,并尝试着加入自动保存到相簿的这个小功能。好吧,有些过于简单了。
保存到相簿1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage]; NSLog(@"SMILE!"); [self.capturedImages addObject:image];
if ([self.cameraTimer isValid]) { return; } if (self.imagePickerController.sourceType == UIImagePickerControllerSourceTypeCamera) { UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); }
[self finishAndUpdate]; }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| - (void)image:(UIImage*)image didFinishSavingWithError:(NSError*)error contextInfo:(void*)contextInfo { UIAlertView *alert; if (error) { alert = [[UIAlertView alloc] initWithTitle:@"错误" message:@"保存失败" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil]; } else { alert = [[UIAlertView alloc] initWithTitle:@"成功" message:@"保存成功" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil]; } [alert show]; }
|
后面要加入的功能