UIImagePickerController在iOS设备上工作但在iOS模拟器上没有?(UIImagePickerController working on iOS device but not on iOS simulator?)
我一直在物理iOS设备上运行我的应用程序一段时间没有任何问题。 但是现在UIImagePickerController视图不会出现在模拟器上。 我已经使用此处的方法将照片保存到模拟器中,并确认它们确实存在于图像库中的模拟器上。 Xcode中没有弹出错误。 我试过玩不同的源类型,但无济于事。 知道我可能做错了什么吗? 非常感谢!
码
UIImagePickerControllerSourceType sourceType; if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) { sourceType = UIImagePickerControllerSourceTypePhotoLibrary; } else { sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; } //Display photo library. [self startImagePickerControllerFromViewController: self usingDelegate: self withSourceType: sourceType]; ... - (BOOL)startImagePickerControllerFromViewController:(UIViewController*) controller usingDelegate:(id <UIImagePickerControllerDelegate, UINavigationControllerDelegate>) delegate withSourceType:(UIImagePickerControllerSourceType) sourceType { //Insure camera, controller, and delegate exist. if (([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera] == NO) || (delegate == nil) || (controller == nil)) return NO; //Create the ImagePicker. UIImagePickerController *imagePickerUI = [[UIImagePickerController alloc] init]; imagePickerUI.sourceType = sourceType; //Only allow still images. imagePickerUI.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeImage, nil]; //Turn off editing. imagePickerUI.allowsEditing = NO; //Set the delegate. imagePickerUI.delegate = delegate; //Present the picker view. [controller presentViewController:imagePickerUI animated:YES completion:nil]; return YES; }
I've been running my app on a physical iOS device for a while now without any problem. But now UIImagePickerController view won't come up on the simulator. I've already saved photos to the simulator using the method here and have confirmed they do exist on the simulator in the image library. There are no errors popping up in Xcode. And I've tried playing around with different source types, but to no avail. Any idea what I might be doing wrong? Thank you much!
Code
UIImagePickerControllerSourceType sourceType; if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) { sourceType = UIImagePickerControllerSourceTypePhotoLibrary; } else { sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; } //Display photo library. [self startImagePickerControllerFromViewController: self usingDelegate: self withSourceType: sourceType]; ... - (BOOL)startImagePickerControllerFromViewController:(UIViewController*) controller usingDelegate:(id <UIImagePickerControllerDelegate, UINavigationControllerDelegate>) delegate withSourceType:(UIImagePickerControllerSourceType) sourceType { //Insure camera, controller, and delegate exist. if (([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera] == NO) || (delegate == nil) || (controller == nil)) return NO; //Create the ImagePicker. UIImagePickerController *imagePickerUI = [[UIImagePickerController alloc] init]; imagePickerUI.sourceType = sourceType; //Only allow still images. imagePickerUI.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeImage, nil]; //Turn off editing. imagePickerUI.allowsEditing = NO; //Set the delegate. imagePickerUI.delegate = delegate; //Present the picker view. [controller presentViewController:imagePickerUI animated:YES completion:nil]; return YES; }
原文:https://stackoverflow.com/questions/23414409
最满意答案
因为在每个循环中你正在进行ajax调用。 所以所有请求几乎同时进行。 并且根据每个ajax调用值的响应时间,将值附加到容器上。 因此,首先应该首先添加它的响应。 这就是为什么订单总是不同的。
如果您希望每次都有相同的订单,请将所有ajax请求排队。 这可以帮助您将所有ajax请求保留在队列中。 请参阅第三个示例“排队类似Ajax调用” http://learn.jquery.com/effects/uses-of-queue-and-dequeue/
Its because inside a each loop you are making ajax call. So all request go almost simultaneously. And depending on the response time taken by each ajax call values are appended on container. So whose response will come first it will be added first. Thats why order is different all the time.
Queue all your ajax request if you want every time same order. This may help you to keep all ajax request on queue. See the third example "Queueing something like Ajax Calls" http://learn.jquery.com/effects/uses-of-queue-and-dequeue/
相关问答
更多-
因为在每个循环中你正在进行ajax调用。 所以所有请求几乎同时进行。 并且根据每个ajax调用值的响应时间,将值附加到容器上。 因此,首先应该首先添加它的响应。 这就是为什么订单总是不同的。 如果您希望每次都有相同的订单,请将所有ajax请求排队。 这可以帮助您将所有ajax请求保留在队列中。 请参阅第三个示例“排队类似Ajax调用” http://learn.jquery.com/effects/uses-of-queue-and-dequeue/ Its because inside a each lo ...
-
您应该检查bpierre对“JavaScript保证对象属性命令吗?”的回答。 。 总结一下,ECMAScript中对象的定义说 这是一个无序的属性集合[...] 在他的回答中,他建议在最新版本的JavaScript中使用Map 。 所以答案是否定的,你不能阻止JavaScript改变JSON的顺序,因为首先没有确定的顺序。 You should check bpierre's answer to "Does JavaScript Guarantee Object Property Order?". To ...
-
您可以编写自定义Manager或覆盖默认Manager 。 默认排序的原始代码位于get_ordering()函数中的https://github.com/django/django/blob/master/django/db/models/sql/compiler.py中。 我没有看到任何方法在查询中轻松添加USING子句。 顺便说一句,如果Django没有正确排序可能是一个错误。 You could write a custom Manager or override the default one. ...
-
$.each()回调的第一个参数是索引,如下所示: $.getJSON("http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/wa/wsSearch?term=paparazzi+lady+gaga&callback=?", function(data) { $.each(data.results, function(i, item) { if(i==o) { console.log("first iteration ...
-
setInterval(update, 0); 您可以尽快生成Ajax请求。 然后你的资源耗尽(可能在第一个请求被处理之前)。 运行update功能一次 ,然后从success和error功能内部再次调用它(最好使用基于setTimeout的延迟)。 setInterval(update, 0); You keep spawning Ajax requests as fast as possible. Then you run out of resources (probably before the ...
-
ORDER BY子句使BigQuery自动展平查询的输出,导致您的查询尝试生成repeated_field_1和repeated_field_2的叉积。 如果您不关心保留字段的重复性,则可以明确地FLATTEN它们,这将导致您的查询生成原始查询所抱怨的交叉产品。 SELECT * FROM FLATTEN(FLATTEN([table], repeated_field_1), repeated_field_2) ORDER BY id DESC LIMIT 10 除此之外,我没有一个很好的解决方法来查询O ...
-
用PHP附加一个json文件(appending a json file with PHP)[2023-08-06]
检查日志,但是,如果你想合并2个数组($ sentdata和$ getdata),你应该使用像array_merge()这样的东西 http://php.net/manual/es/function.array-merge.php 有了这个: foreach($sentdata as $value) $getdata[] = $value; 你失去了你的钥匙(而且它很慢) 顺便说一句...你的附加json是无效的json ... check the log, but, if you want to ... -
data.query.search,我认为它应该是data.data和里面的函数data.title有些想像... $.each(data.data, function(i, data) { $("#results").append(data.title+" "+data.permalink); }); data.query.search, I think it should be data.data and inside function data.title some think like... $.e ...
-
改变|(Changing | manipulating json elements or appending namespace prefixes to json elements)[2022-03-18]
这总是这样的: prime = JSON.parse( JSON.stringify(prime).replace(/startNode/g, 'tns:startNode') ); 这将为您提供有效的JSON对象,但如果您想输出JSON的字符串表示,则可能甚至不需要parse 。 我不确定这是否比通过JSON更新密钥更多或更少。 There's always this: prime = JSON.parse( JSON.stringify(prime).replace(/startNode/g, 'tns ... -
使用ES6,您可以使用Array#find方法: response.find(o => o.entity_id == 'sensor.out').state 请参阅代码段: var response = [ { "attributes":{ "friendly_name":"door" }, "entity_id":"sensor.door", "last_changed":"2016-12-31T11:15:59.395808+00:00", "last_updated":"2016-12-31T11: ...