【问题标题】:On UIWebView not able to select photo?在 UIWebView 上无法选择照片?
【发布时间】:2017-07-01 19:15:15
【问题描述】:

我正在 UIWebView 上加载 URL,该 URL 照片选择选项在那里,当我单击“选择文件”时,照片选择警报会像 下图:--- /Users/ArjunSinghBaghel/桌面/屏幕截图 2017-02-13 在 11.06.02 PM.png

但是当我点击“照片库”时,该页面会消失。

请帮帮我..

提前致谢。

【问题讨论】:

  • 更正你的截图:)

标签: ios objective-c iphone uiwebview uiimagepickercontroller


【解决方案1】:

正如调试器中记录的警告所暗示的那样,UIImagePickerController 没有被正确调用。
考虑这个例子,

- (void)takePhoto:(UIButton *)sender{
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    [self presentViewController:picker animated:YES completion:nil]; 
}

确认正在使用的self 是否是UIViewController 的子类,该子类已添加到UINavigatorController Bar 堆栈中。
在当前场景中,self 似乎是UIView 实例。

【讨论】:

    【解决方案2】:

    您可能需要在Info.plist 文件中设置适当的权限。即Privacy - Photo Library Usage DescriptionPrivacy - Camera Library Usage Description

    或者,您可以使用WKWebView。我刚刚在装有 IOS 10 的 iPad 上的 Swift Playgrounds 中测试了 Swift 实现,它运行良好。请参阅https://gist.github.com/kiritmodi2702/b8a674bb66803c1397cab55030ae2c54

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-12-10
    • 1970-01-01
    • 2013-10-01
    • 1970-01-01
    • 2013-01-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多