【发布时间】:2013-07-17 08:35:22
【问题描述】:
我知道如何保存图片,这是迄今为止的代码。此代码显示用户点击一个按钮并能够拍照。
-(IBAction)TakePhoto {
picker = [[UIImagePickerController alloc]init];
picker.delegate = self;
[picker setSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentViewController:picker animated:YES completion:nil];
}
- (IBAction)ChooseExisting {
picker2 = [[UIImagePickerController alloc]init];
picker2.delegate = self;
[picker2 setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:picker2 animated:YES completion:nil];
}
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
image = [info objectForKey:UIImagePickerControllerOriginalImage];
[imageview setImage:image];
//Save Your Image ======
UIImage *yourImage = imageview.image;//imageView.image;
NSString *docDirPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString *filePath = [docDirPath stringByAppendingPathComponent:@"myImageFile.png"];
[UIImagePNGRepresentation(yourImage) writeToFile:filePath atomically:YES];
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[self dismissViewControllerAnimated:YES completion:NULL];
}
但是,我想将我保存的图片分类为 6 个类别或流派,用户必须使用分段视图控件点击这些类别或流派。这可能吗?我对 ios 编程和 xcode 中的 Objective-c 非常陌生,并且对许多视图控制器感到困惑,但是我真的很喜欢这个工作,我找不到关于这个主题的任何资源。谢谢。
【问题讨论】:
-
您希望用户选择要保存到的类别吗?
-
是的!用户在应用程序内拍照并保存,以便用户可以在应用程序中而不是在照片库中看到图片..