有没有人遇到过这个问题?我正在使用 UIImagePickerController 相机通过我的应用程序拍照,我注意到照片在拍摄后没有存储在照片库中。我已经在带有 iPhone4 的 iOS5 和带有 iPhone5 的 iOS6 上都试过了,结果相同。以下是我的设置方式:
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
}
imagePickerController.delegate = self;
[self.navigationController presentModalViewController:imagePickerController animated:YES];
[imagePickerController release];
似乎 UIImagePickerController 应该隐式保存拍摄到用户照片库的照片?任何帮助将不胜感激。
最佳答案
尝试以下代码。
-(IBAction)useCamera
{
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeImage,
nil];
imagePicker.allowsEditing = NO;
[self presentViewController:imagePicker animated:YES completion:nil];
newMedia = YES;
}
}
#pragma mark- camera picker delegate methods
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *mediaType = [info
objectForKey:UIImagePickerControllerMediaType];
[self dismissViewControllerAnimated:YES completion:nil];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
UIImage *image = [info
objectForKey:UIImagePickerControllerOriginalImage];
[imageView setAutoresizingMask:(UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth)];
imageView.image = image;
if (newMedia)
UIImageWriteToSavedPhotosAlbum(image,
self,
@selector(image:finishedSavingWithError:contextInfo:),
nil);
}
else if ([mediaType isEqualToString:(NSString *)kUTTypeMovie])
{
// Code here to support video if enabled
}
}
-(void)image:(UIImage *)image
finishedSavingWithError:(NSError *)error
contextInfo:(void *)contextInfo
{
if (error) {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: @"Save failed"
message: @"Failed to save image"\
delegate: nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
}
从相机中选取照片并将其存储到 ImageView 并调用 save 方法将其保存到相机胶卷。 希望这会有所帮助
关于iphone - UIImagePickerController 相机不在照片库中保存照片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14134854/
我想向我的Controller传递一个参数,它是一个简单的复选框,但我不知道如何在模型的form_for中引入它,这是我的观点:{:id=>'go_finance'}do|f|%>Transferirde:para:Entrada:"input",:placeholder=>"Quantofoiganho?"%>Saída:"output",:placeholder=>"Quantofoigasto?"%>Nota:我想做一个额外的复选框,但我该怎么做,模型中没有一个对象,而是一个要检查的对象,以便在Controller中创建一个ifelse,如果没有检查,请帮助我,非常感谢,谢谢
我刚刚被困在这个问题上一段时间了。以这个基地为例:moduleTopclassTestendmoduleFooendend稍后,我可以通过这样做在Foo中定义扩展Test的类:moduleTopmoduleFooclassSomeTest但是,如果我尝试通过使用::指定模块来最小化缩进:moduleTop::FooclassFailure这失败了:NameError:uninitializedconstantTop::Foo::Test这是一个错误,还是仅仅是Ruby解析变量名的方式的逻辑结果? 最佳答案 Isthisabug,or
📢博客主页:https://blog.csdn.net/weixin_43197380📢欢迎点赞👍收藏⭐留言📝如有错误敬请指正!📢本文由Loewen丶原创,首发于CSDN,转载注明出处🙉📢现在的付出,都会是一种沉淀,只为让你成为更好的人✨文章预览:一.分辨率(Resolution)1、工业相机的分辨率是如何定义的?2、工业相机的分辨率是如何选择的?二.精度(Accuracy)1、像素精度(PixelAccuracy)2、定位精度和重复定位精度(RepeatPrecision)三.公差(Tolerance)四.课后作业(Post-ClassExercises)视觉行业的初学者,甚至是做了1~2年
我有一个带有利润字段的用户模型。利润字段是DECIMAL(11,0)类型。我在表单上有一个屏蔽输入,允许用户输入1,000美元之类的内容。我想格式化该值并从中删除除数字以外的所有内容,这样我将保存1000。这是我到目前为止所拥有的:classUser但它一直在数据库中保存0。看起来它在我的格式化函数之前将其转换为十进制。 最佳答案 试试这个:defprofit=(new_profit)self[:profit]=new_profit.gsub(/[^0-9]/,'')end 关于ruby
您好,我在Rails2应用程序中集成了ZohoSheet,我可以从本地打开新的ZohoSheet,但是当我在zoho编辑器中单击保存时,它会将文件发送到我的服务器,这是我的生产日志ProcessingZohoController#indexto#(for*.*.*.*at2015-10-0811:24:08)[POST]Parameters:{"controller"=>"zoho","filename"=>#,"content"=>#,"eventsource"=>#,"format"=>#,"id"=>#,"action"=>"index"}ActionController::In
我的Rails应用程序在rails4.0.2上,我在使用locale变量和params[:locale]切换翻译时遇到问题官方railsguide.我在mysite有一个单页网站.我的国际化路线:scope"(:locale)",locale:/en|de/do#myrouteshereend我的应用程序Controllerbefore_filter:set_localedefset_localeI18n.locale=params[:locale]||I18n.default_locale#Rails.application.routes.default_url_options[:l
更新:当输入“passenger-memory-stats”时,我显示:---Passengerprocesses---Processes:0我该如何解决这个问题?为什么即使我在httpd.conf中添加它并重新启动apache,passenger也不会启动?我无法让PhusionPassenger在服务器上运行RubyonRails。我已经按照Phusion网站上的所有说明安装了passenger并修改并创建了ApacheVirtualHost以指向新目录并验证所有.conf文件都已成功加载。还加载了httpd-Mpassenger_module。我还在本地主机上成功运行了Passe
我正在尝试在Rails中创建一个产品页面。这包括添加多个图像和文本字段。我有一个产品模型和一个照片模型。我正在使用回形针gem上传照片。但是当我查看产品页面时,我看不到图片。照片未保存到数据库。附言我使用HAML。app/views/products/show.html.haml%bName=@product.name%br%bDescription=@product.description%br-@product.photos.eachdo|photo|=image_tagphoto.image.urlapp/controllers/products_controllerclassP
对Rails来说有点新,但有点新。其中一个模型在has_many/belongs_to关联中依赖于另一个模型。基本上,在我的应用程序上创建“帖子”时,用户还可以附加“图片”。理想情况下,这是两个独立的模型。当用户选择一张照片时,一些JavaScript将其上传到Cloudinary,返回的数据(ID、宽度、高度等)被JSON字符串化并设置在隐藏字段上。#TheHTML=f.hidden_field:images,:multiple=>true,:class=>"image-data"#Setourimagedataonthehiddenfieldtobeparsedbytheserve
我的mock只有在如下所示的beforeblock中时才有效。这只是我对我的问题的快速而肮脏的表述。从字面上看,当我将行从beforeblock移动到doesnotquack断言时,它停止模拟:(describe'Ducks',type::featuredobeforedo...allow_any_instance_of(Duck).toreceive(:quack).and_return('bark!')visitanimal_farm_pathendcontext'isanoddduck'it'doesnotquack'doexpect(Duck.new.quack).toeq('