我知道如何保存圖片,這是迄今爲止的代碼。此代碼顯示用戶點擊一個按鈕並能夠拍照。用數據保存圖片
-(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,並與許多視圖控制器混淆,但我真的很喜歡這個工作,我無法找到任何關於此主題的資源。謝謝。
你希望用戶選擇一個類別保存到? – user523234
是的!用戶在應用程序內拍照並保存,以便用戶可以在應用程序中看到圖片而不在照片庫中。 – user2590480