Github项目地址
================
项目来自于苹果官方文档中的一个范例。
针对这个范例,我对一些英文注释做了中文说明,并尝试着加入自动保存到相簿的这个小功能。好吧,有些过于简单了。
// 当从相册里选择一张照片或者用相机进行拍摄之后,该方法被调用
- (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];
}
- (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];
}
后面要加入的功能
- 将拍照的照片存储到应用沙盒中