iOS 6“HTML输入文件标签”如果在UIWebView中加载网页,则不起作用 [英] iOS 6 "HTML Input file tag" doesn't work if load the web page in UIWebView
问题描述
我们知道在iOS 6移动版Safari中支持HTML输入文件标签来上传图片。我刚刚创建了一个这样的HTML文件,并且在移动Safari中运行良好。但是当我将它加载到UIWebView中时,我发现我仍然可以点击选择文件按钮来选择一个图像文件,但是当我点击完成并返回到UIWebView后,UIWebView中的网页被重新加载并且没有文件被附加到HTML表单。这是对UIWebView的限制吗?
我对它进行了整理。这是由于我把UIWebview的加载网页功能放在-viewWillAppear:(BOOL)animated中。所以每次当拍照模式视图隐藏时,UIWebview会重新加载url。我修复了它,现在我可以确认HTML输入文件标签上传功能在UIWebview中也能很好地工作。
We know that in iOS 6 mobile safari supports HTML input file tag to upload images. I just created an HTML file like this and it worked fine in mobile safari. But when I loaded it in a UIWebView, I found I could still tap the "Choose file" button to choose an image file, but after I tapped "done" and returned to the UIWebView, the web page in the UIWebView reloaded and no file was attached to the HTML form. Is that a restriction to UIWebView?
I have sorted it out. This is due to I put the UIWebview loading web page function in "-viewWillAppear:(BOOL)animated". So each time when the "take photo" modal view hides, the UIWebview reloads the url. I have fixed it and I can confirm now that the HTML input file tag upload function works well in UIWebview, too.
这篇关于iOS 6“HTML输入文件标签”如果在UIWebView中加载网页,则不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!