背景&短い要約にのiPadシミュレータの罰金が、私は私のアプリのためのWebページを表示するためにWkWebviewを使用していますWKWebview
を使用して画像をアップロードする際にiPadはアプリがクラッシュします。カメラや写真ライブラリから画像を選択できるようにしました。しかし、画像の選択時にアプリがクラッシュするという問題があるようです。
仕様
私は私はシミュレータ上XCodeの8から両方
を実行していますスウィフト3を使用して、シミュレータ上で、タブレット上のIOS 10.0.2上で実行されている、およびIOS 10.0ています
2016-10-19 02:15:36.150670 z4[31561:14708540] [Generic]
Creating an image format with an unknown type is an error
:画像
私は、次のメッセージが表示されますをアップロードしようとすると「エラー」を取得
画像は正常ですので、アップロードに使用できます。この動作は、私は奇妙だと思ったが、私はそれは私がアプリはAppDelegateにクラッシュするようで、次の
Terminating app due to uncaught exception 'NSGenericException',
reason: 'Your application has presented a
UIAlertController (<UIAlertController: 0x151e80350>)
of style UIAlertControllerStyleActionSheet.
The modalPresentationStyle of a UIAlertController
with this style is UIModalPresentationPopover.
You must provide location information for this
popover through the alert controller's popoverPresentationController.
You must provide either a sourceView and sourceRect or a barButtonItem.
If this information is not known when you present the alert controller,
you may provide it in the UIPopoverPresentationControllerDelegate method
-prepareForPopoverPresentation.'
を得る錠剤自体でIOS
上のメモリ管理に関係していることを読みました。私は彼らの推薦をどうやって行うのか分かりません。これが深刻な問題の一部であるかどうか、あるいは私が本当に簡単なものを見逃しているかどうかもわかりません。私は、次のUIAlerts
に関連している
コードは、私は、この例外を処理し、私のアプリにはないので、この問題を解決するにはどうすればよい私はUIAlertController
func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping() -> Void) {
let alertController = UIAlertController(title: nil, message: message, preferredStyle: .actionSheet)
alertController.addAction(UIAlertAction(title: "Ok", style: .default, handler: { (action) in
completionHandler()
}))
self.popoverPresentationController?.sourceView = self.view
self.popoverPresentationController?.sourceRect = self.view.bounds
self.present(alertController, animated: true, completion: nil)
}
func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (Bool) -> Void) {
let alertController = UIAlertController(title: nil, message: message, preferredStyle: .actionSheet)
alertController.addAction(UIAlertAction(title: "Yes", style: .default, handler: { (action) in
completionHandler(true)
}))
alertController.addAction(UIAlertAction(title: "No", style: .default, handler: { (action) in
completionHandler(false)
}))
self.popoverPresentationController?.sourceView = self.view
self.popoverPresentationController?.sourceRect = self.view.bounds
self.present(alertController, animated: true, completion: nil)
}
func webView(_ webView: WKWebView, runJavaScriptTextInputPanelWithPrompt prompt: String, defaultText: String?, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (String?) -> Void) {
let alertController = UIAlertController(title: nil, message: prompt, preferredStyle: .actionSheet)
alertController.addTextField { (textField) in
textField.text = defaultText
}
alertController.addAction(UIAlertAction(title: "Yes", style: .default, handler: { (action) in
if let text = alertController.textFields?.first?.text {
completionHandler(text)
} else {
completionHandler(defaultText)
}
}))
alertController.addAction(UIAlertAction(title: "No", style: .default, handler: { (action) in
completionHandler(nil)
}))
self.popoverPresentationController?.sourceView = self.view
self.popoverPresentationController?.sourceRect = self.view.bounds
self.present(alertController, animated: true, completion: nil)
}
に関連している3つの機能です私にクラッシュ?必要に応じて詳細とコードを提供することができます。事前にあなたの助けをありがとう。
self.popoverPresentationControllerは、実際にgetOnly方法である、と私はalterController.modalPresentationStyleをアンインストールし、再インストール時に= .popoverは動作しませんでした。 – applecrusher
さらに検索した後、ファイルピッカーを使用していると同時にアラートを出していたので、それは問題の束を引き起こしていたという事実と関係していました – applecrusher
もう一度壊れたようです。 – applecrusher