2017-09-07 7 views
1

私はUIWebViewからWKWebViewへの移行を行っています。 1つのエラーに直面しているものをすべて変更した後、メンバー 'first(where)'へのあいまいな参照。この問題を解決するのを手伝ってください。私はWKWebViewメンバーへのあいまいな参照 'first(where)'

WKWebView 

func share(sender: WKWebView) { 

     if let url: URL = webViews.first?.load?.url 
     { 
      do { 
       let base64Data = try Data(contentsOf: url) 
       let activityController: UIActivityViewController = UIActivityViewController(activityItems: [base64Data], applicationActivities: nil) 
       present(activityController, animated: true, completion: nil) 
      } catch { 
       displayAlert(Localizations.Error, message: Localizations.Apierror, responder: nil, completion: nil) 
      } 
     } 
    } 
この行のエラーに直面し

if let url: URL = webViews.first?.load?.url

+0

あなたの 'webViews'のタイプは何ですか? – nyg

+0

fileprivate let webViews:[WKWebView] @nyg – Siva

+0

WebViewsに項目を追加する場所にコードを表示できますか? – 3stud1ant3

答えて

1

WKWebViewにコード上方に変更

UIWebView 

func share(sender: UIWebView) { 
     if let url: URL = webViews.first?.request?.url { 
      do { 
       let base64Data = try Data(contentsOf: url) 
       let documentURL = try savePDF(base64Data) 
       documentInteractionController = UIDocumentInteractionController(url: documentURL) 
       documentInteractionController?.presentOptionsMenu(from: shareButton, animated: true) 
      } catch { 
       displayAlert(Localizations.Error, message: Localizations.Apierror, responder: nil, completion: nil) 
      } 
     } 
    } 

のみload(_:)、全く性loadを有していません。あなたがしたいことは多分です:

if let url = webViews.first?.url { 
    // .. 
} 
関連する問題