我现在正在使用位于Resources文件夹中的1个字符串中的硬编码图像,然后通过上传和下载 处理该字符串。
我的第一项任务仍然存在。 我想通过相机捕获图像,并希望保存到Resources文件夹中,并且还想将其赋予1个字符串。
答案 0 :(得分:0)
如果要在某处显示图像,可以使用:
-(void)chooseImageFromCamera {
if( ![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] ) return;
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.delegate = self;
picker.allowsEditing = YES;
picker.wantsFullScreenLayout = YES;
[currentItem retain];
[self presentModalViewController:picker animated:YES];
}
#pragma mark Image Picker Delegates
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo {
NSData *chosenImage = UIImageJPEGRepresentation(image, 1.0);
/* change this to the path of a plist file */
NSString *current = [NSString stringWithFormat:@"PlistFile.plist"];
NSMutableDictionary* plistDict = [[[NSMutableDictionary alloc] initWithContentsOfFile:current] autorelease];
// Do something with the image here.
[plistDict setObject:chosenImage forKey:@"Photo"];
[plistDict writeToFile:current atomically:YES];
[self dismissModalViewControllerAnimated:YES];
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
}