【发布时间】:2015-07-15 08:39:08
【问题描述】:
我在视图中嵌入了UIWebView。
如果点击此 web 视图页面中的任何文件字段,将显示默认的 UIImagePicker。
如何获取此默认选择器或设置其委托?
这是我的 Object-C 代码
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://jsfiddle.net/wowaqpcf/embedded/result/"]]];
[webView setDelegate:self];
[self.view addSubview:webView];
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
return YES; // => set breakpoint at this line -> it doesn't stop when picker opens
}
@end
或者在iPhone上通过safari打开this page,你就会明白我的意思了。
<form>
<input type="file">
</form>
我尝试捕捉webView:shouldStartLoadWithRequest:navigationType:,但似乎呈现这个选择器并不通过委托方法。 (我认为这个选择器可能会通过导航到一个特殊的方案来呈现)
非常感谢。
【问题讨论】:
-
你想为选择器或网页视图实现委托吗?你哪里有问题
-
我想为网络视图的“默认”选择器实现委托
-
添加更多代码或输出的快照
-
你现在尝试过只实现
didFinishPickingMediaWithInfo -
你找到解决办法了吗?
标签: ios objective-c swift uiwebview uiimagepickercontroller