- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个应用程序,用户将从 UIImagePickerView
中选择图像。
从中选择图像后,我想将其保存在我的应用程序中。
如何实现这一目标?
预先感谢您对我的帮助。
最佳答案
假设您使用的是 SDK 3.0,以下是一些将图像保存到应用程序的文档文件夹中的代码:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Dismiss the picker
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
// Get the image from the result
UIImage* image = [info valueForKey:@"UIImagePickerControllerOriginalImage"];
// Get the data for the image as a PNG
NSData* imageData = UIImagePNGRepresentation(image);
// Give a name to the file
NSString* imageName = "MyImage.png";
// Now, we have to find the documents directory so we can save it
// Note that you might want to save it elsewhere, like the cache directory,
// or something similar.
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* documentsDirectory = [paths objectAtIndex:0];
// Now we get the full path to the file
NSString* fullPathToFile = [documentsDirectory stringByAppendingPathComponent:imageName];
// and then we write it out
[imageData writeToFile:fullPathToFile atomically:NO];
return;
}
关于iphone - 如何保存 UIImagePickerView Controller 返回的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1269214/
我正在像这样实例化一个 UIImagePicker: self.picker = [[UIImagePickerController alloc] init]; [self.picker setDel
我在我的代码中使用UIImagePickerView,其中有三个按钮。一键拍照,二键选择照片,三键取消。代码如下: UIActionSheet *actionSheet = [[UIActionShe
我有两个按钮,button1 和button2。点击这些按钮将显示 UIImagePickerViewController。在委托(delegate)方法 didFinishPickingMediaW
我正在尝试调用 UIImagePickerView,有时当我的相机 View (带有自定义覆盖)出现时,它最初会提供黑色预览。 15-30 秒后黑屏消失。如果用黑色相机屏幕单击图像,它仍会显示在我的
我想在 UIImagepickerview 上添加一个带有一些自定义按钮的自定义叠加层。 如果有人能给我一个或 2 个教程链接,我将不胜感激。 谢谢 最佳答案 这是一个 PhotoPicker 示例代
我有一个应用程序,用户将从 UIImagePickerView 中选择图像。 从中选择图像后,我想将其保存在我的应用程序中。 如何实现这一目标? 预先感谢您对我的帮助。 最佳答案 假设您使用的是 SD
我的 iPhone 应用程序中有一个 UIImagePicker View ,我想隐藏相机控件。我该怎么做? 最佳答案 有一个 showsCameraControls 属性可以禁用: myImageP
我使用 KIF 框架编写了测试用例。使用 UIIMagePicker View 从图库中获取图像的问题 -操作系统版本为 7.0+ 并且KIF 版本为 2.2。 我正在使用下面的代码行从图库中获取图像
我有一个应用程序使用 UIImagePickerView 允许用户使用他们的相机拍照或使用 UIImagePickerView 从相机胶卷中选择一张照片。 获取图片后,我使用 [picker pres
我是一名优秀的程序员,十分优秀!