我在iOS上的 WKWebView 遇到问题。点按元素<input type="file" accept="image/*">
后,将显示带有三个选项的ActionSheet:图片库,iCloud,取消。
然后,当我点击照片库时,ActionSheet消失了,并且WebView阻止再次打开ActionSheet。我很困惑,无法通过WebView上传照片。
我已经在info.plist文件中添加了权限(隐私-图片库使用说明)。这是我创建WebView的方法
WKWebViewConfiguration *wkConfiguration = [[WKWebViewConfiguration alloc] init];
wkConfiguration.allowsInlineMediaPlayback = true;
wkConfiguration.mediaPlaybackRequiresUserAction = false;
self.webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:wkConfiguration];
self.webView.scrollView.bounces = NO;
self.webView.contentScaleFactor = 2.0;
self.webView.exclusiveTouch = YES;
[self.webView.scrollView setDelaysContentTouches:NO];
[self.webView.scrollView setDecelerationRate:UIScrollViewDecelerationRateNormal];
self.webView.UIDelegate = self;
self.webView.navigationDelegate = self;
最糟糕的是,我无法在输入中捕获轻击事件。也许有人有类似的问题?我在Stack和Apple论坛中搜索了其他主题,但都没有帮助。感谢您的帮助。已编辑
系统日志正在打印:
<Error>: -[NETAWDManager reportStats:metricID:] AWDServerConnection newMetricContainerWithIdentifier failed for metric 2686983, server 0x16d62570, not reporting:
<AWDLibnetcoreTCPConnectionReport: 0x16e418a0> {
cellularFallbackReport = {
dataUsageSnapshotsAtNetworkEvents = (
{
bytesIn = 1999999;
bytesOut = 1600;
}
);
"fallbackTimer_msecs" = 0;
fellback = 0;
networkEvents = (
"NETWORK_EVENT_DATA_STALL_AT_APP_LAYER"
);
"timeToNetworkEvents_msecs" = (
5168
);
};
clientIdentifier = "com.apple.WebKit.Networking";
connectionStatisticsReport = {
DNSAnswersCached = 0;
"DNSResolvedTime_msecs" = 0;
RTTvariance = 0;
"appDataStallTimer_msecs" = 3;
appReportingDataStallCount = 1;
"bestRTT_msecs" = 0;
betterRouteEventCount = 0;
bytesDuplicate = 0;
bytesIn = 2700000;
bytesOut = 3800;
bytesOutOfOrder = 0;
bytesRetransmitted = 0;
cellularFallback = 0;
cellularRRCConnected = 0;
connected = 1;
connectedInterfaceType = "(unknown: 4)";
"connectionEstablishmentTime_msecs" = 1;
connectionReuseCount = 0;
"currentRTT_msecs" = 0;
"flowDuration_msecs" = 40208;
interfaceType = "(unknown: 4)";
kernelReportedStalls = 0;
kernelReportingConnectionStalled = 0;
kernelReportingReadStalled = 0;
kernelReportingWriteStalled = 0;
packetsDuplicate = 0;
packetsIn = 210;
packetsOut = 9;
packetsOutOfOrder = 0;
packetsRetransmitted = 0;
"smoothedRTT_msecs" = 0;
synRetransmissionCount = 0;
tcpFastOpen = 0;
"timeToConnectionEstablishment_msecs" = 2;
"timeToConnectionStart_msecs" = 1;
"timeToDNSResolved_msecs" = 0;
"timeToDNSStart_msecs" = 0;
trafficClass = 0;
};
delegated = 1;
reportReason = "REPORT_REASON_DATA_STALL_AT_APP_LAYER";
sourceAppIdentifier = "com.supermemo.sm-com";
}
Jul 6 10:13:59 iPad-xxx assistantd[268] <Error>: tcp_connection_tls_session_error_callback_imp 7 __tcp_connection_tls_session_callback_write_block_invoke.434 error 22
Jul 6 10:13:59 iPad-xxx assistantd[268] <Error>: NSURLSessionStreamTask: TCPConnection read invalidated by closed connection
Jul 6 10:13:59 iPad-xxx networkd[87] <Error>: -[NETAWDManager reportStats:metricID:] AWDServerConnection newMetricContainerWithIdentifier failed for metric 2686980, server 0x16d62570, not reporting:
<AWDMPTCPConnectionReport: 0x16d3ab50> {
"client_id" = assistantd;
"establishment_cellular_fallback" = 0;
"establishment_failure_error" = 0;
"establishment_forced_tcp_fallback" = 0;
"establishment_interface_name" = en0;
"establishment_success" = 1;
"establishment_syn_retransmits" = 0;
"establishment_tcp_fallback" = 0;
"establishment_time" = "0.0573505";
"interface_reports" = (
{
"data_in_KB" = 5;
"data_out_KB" = 2;
"interface_name" = en0;
"post_connect_subflow_failure_errors" = (
);
"post_connect_tcp_fallback_count" = 0;
"secondary_flow_failure_count" = 0;
"secondary_flow_success_count" = 0;
}
);
"post_connect_multi_homed" = 1;
"post_connect_session_lifetime" = "42.711159041";
"post_connect_single_homed" = 0;
"post_connect_subflow_attempt_count" = 2;
"post_connect_subflow_max_subflow_count" = 1;
"subflow_switching_count" = 0;
}
WKWebView使用某种安全协议从OS提取文件吗?有人知道如何处理吗? 最佳答案
我终于解决了。我必须实现UIViewController方法:
-(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
{
if (self.presentedViewController){
[super dismissViewControllerAnimated:flag completion:completion];
}
关于ios - WKWebview和<input type =“file”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44848761/