iOS 8.0 UIWebView file input crashes my App

不羁的心 提交于 2019-12-18 16:51:38

问题


After updating to iOS 8.0 clicking the "Choose file" button (HTML file input) and then clicking "Take photo or Video" / "Choose Existing" crashes my App.

This functionality has been working perfectly fine since iOS 6 but in iOS 8.0 the file input functionality is completely broken!

Do any one else experience the same problem with there UIWebView Apps?


回答1:


The solution to this problem is as Joel Jeske writes, you have to rebuild your App against iOS 8. This is the only solution to this problem. Rebuilding against iOS 8 will also make the App run on iOS 7/6 without any problem.




回答2:


I was having a similar issue, and I have discovered that the UIWebView elements in IOS do not support the html element:

<input type="file">

I am not sure why Apple chose to not support this IMPORTANT html element, but I am sure they have their reasons. (Even though this element works perfectly on Safari on IOS.)

In many cases, when the user clicks this kind of button in a UIWebView, it will let them take/ choose a photo. HOWEVER, the UIWebView in IOS does not have the capability to attach files like this into the POST data when the form is submitted.

The Solution: To accomplish the same task you can create a similar form in InterfaceBuilder with a button that triggers the UIImagePickerController. Then, you create you an HTTP POST request with all of the form data and the image. It isn't as hard as it sounds, check out the link below for some sample code that gets the job done: ios Upload Image and Text using HTTP POST




回答3:


I had the same problem and discovered that adding the attribute multiple fixed the problem for me.

<input type="file" accept="image/*" multiple />



回答4:


I believe that it is not that apple has stopped supporting the <input> field on HTML at all. It is down to the developer not declaring that the app is using the following privacy elements in the plist (NSPhotoLibraryUsageDescription , NSCameraUsageDescription). please refer to the following page on stackoverflow NSPhotoLibraryUsageDescription in Xcode8

Basically I had the same problem but once I added these elements with a description everything work fine like nothing happened.




回答5:


I had the same problem. The reason is a category, it has a method named pathExtension in my code, and the category covered the NSString(NSStringPathExtension). So I renamed the method, and now it's ok.



来源:https://stackoverflow.com/questions/25898564/ios-8-0-uiwebview-file-input-crashes-my-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!