{"id":248,"date":"2017-10-17T23:42:39","date_gmt":"2017-10-17T14:42:39","guid":{"rendered":"https:\/\/jidouka.work\/?p=248"},"modified":"2017-10-17T23:46:09","modified_gmt":"2017-10-17T14:46:09","slug":"%e3%82%a2%e3%83%97%e3%83%aa%e3%82%92iphone-x%e3%81%ab%e5%af%be%e5%bf%9c%e3%81%95%e3%81%9b%e3%82%8b%ef%bc%88webview%e7%b7%a8%ef%bc%89","status":"publish","type":"post","link":"https:\/\/jidouka.work\/?p=248","title":{"rendered":"\u30a2\u30d7\u30ea\u3092iPhone X\u306b\u5bfe\u5fdc\u3055\u305b\u308b\uff08WebView\u7de8\uff09"},"content":{"rendered":"<p>\u3088\u3053\u306d\u3063\u3068\u306e\u30a2\u30d7\u30ea\u3067\u3042\u308bFlash Photos\u306fAbout\u306e\u60c5\u5831\u306e\u8868\u793a\u306bUIWebView\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\nUIWebView\u3092\u4f7f\u7528\u3057\u3066HTML\u3092\u8868\u793a\u3057\u3066\u3044\u308b\u7406\u7531\u306f\u3001\u30d0\u30fc\u30b8\u30e7\u30f3\u30a2\u30c3\u30d7\u7b49\u306b\u3088\u3063\u3066\u5185\u5bb9\u3092\u66f8\u304d\u5909\u3048\u308b\u969b\u306b\u30b3\u30fc\u30c9\u3092\u3044\u3058\u308b\u5fc5\u8981\u304c\u306a\u304f\u3001HTML\u30d5\u30a1\u30a4\u30eb\u306e\u307f\u3092\u7de8\u96c6\u3059\u308c\u3070\u826f\u3044\u304b\u3089\u3067\u3059\u3002<br \/>\n\u3057\u304b\u3057\u3001iPhone X\u306e\u30b7\u30df\u30e5\u30ec\u30fc\u30bf\u3067\u52d5\u304b\u3057\u305f\u3068\u3053\u308d\u3001\u30bb\u30fc\u30d5\u30a8\u30ea\u30a2\u5916\u306e\u90e8\u5206\u306f\u30b0\u30ec\u30fc\u306b\u306a\u3063\u3066\u304a\u308a\u3001UIWebView\u304c\u5168\u753b\u9762\u306b\u8868\u793a\u3055\u308c\u306a\u3044\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u7e26\u4f4d\u7f6e\u3060\u3068\u4e0b\u5074\u307e\u3067UIWebView\u304c\u4f38\u3073\u3066\u3044\u307e\u305b\u3093\u3002<\/p>\n<p><a href=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/10\/4d8465ff4dd1f329ecf946062b5869c1.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/10\/4d8465ff4dd1f329ecf946062b5869c1-1020x1024.jpg\" alt=\"\" width=\"790\" height=\"793\" class=\"alignnone size-large wp-image-249\" srcset=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/10\/4d8465ff4dd1f329ecf946062b5869c1-1020x1024.jpg 1020w, https:\/\/jidouka.work\/wp-content\/uploads\/2017\/10\/4d8465ff4dd1f329ecf946062b5869c1-150x150.jpg 150w, https:\/\/jidouka.work\/wp-content\/uploads\/2017\/10\/4d8465ff4dd1f329ecf946062b5869c1-300x300.jpg 300w, https:\/\/jidouka.work\/wp-content\/uploads\/2017\/10\/4d8465ff4dd1f329ecf946062b5869c1-768x771.jpg 768w, https:\/\/jidouka.work\/wp-content\/uploads\/2017\/10\/4d8465ff4dd1f329ecf946062b5869c1.jpg 1049w\" sizes=\"auto, (max-width: 790px) 100vw, 790px\" \/><\/a><\/p>\n<p>\u6a2a\u8868\u793a\u3060\u3068Sensor Housing\u5468\u8fba\u306bView\u304c\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p><a href=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/10\/eb0c386f1d33c865e524c312c7a95d00.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/10\/eb0c386f1d33c865e524c312c7a95d00.jpg\" alt=\"\" width=\"904\" height=\"553\" class=\"alignnone size-full wp-image-250\" srcset=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/10\/eb0c386f1d33c865e524c312c7a95d00.jpg 904w, https:\/\/jidouka.work\/wp-content\/uploads\/2017\/10\/eb0c386f1d33c865e524c312c7a95d00-300x184.jpg 300w, https:\/\/jidouka.work\/wp-content\/uploads\/2017\/10\/eb0c386f1d33c865e524c312c7a95d00-768x470.jpg 768w\" sizes=\"auto, (max-width: 904px) 100vw, 904px\" \/><\/a><\/p>\n<p>\u3053\u306e\u3088\u3046\u306a\u8868\u793a\u3067\u3082\u4f7f\u7528\u4e0a\u306f\u554f\u984c\u306f\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u898b\u305f\u76ee\u304c\u60aa\u304f\u3001iPhone X\u306eSafari\u3060\u3068View\u304c\u5168\u753b\u9762\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u306e\u3067\u3001Flash Photos\u306eAbout\u753b\u9762\u3082\u5168\u753b\u9762\u3092\u4f7f\u7528\u3057\u3066HTML\u3092\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<h2>UIWebView\u304b\u3089WKWebView\u3078\u306e\u5909\u66f4<\/h2>\n<p>\u8868\u793a\u304c\u304a\u304b\u3057\u304f\u306a\u308b\u539f\u56e0\u306fUIWebView\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u305f\u3081\u3067\u3059\u3002UIWebView\u306fiOS8\u4ee5\u964d\u3067\u306fWKWebView\u3092\u4f7f\u3046\u3088\u3046\u306b\u63a8\u5968\u3055\u308c\u3066\u304a\u308a\u3001Xcode9\u3067\u306f\u4e00\u5fdc\u4f7f\u3048\u307e\u3059\u304cdeprecated\u3068\u3044\u3046\u6271\u3044\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<blockquote><p>Note<br \/>\nIn apps that run in iOS 8 and later, use the WKWebView class instead of using UIWebView. Additionally, consider setting the WKPreferences property javaScriptEnabled to false if you render files that are not supposed to run JavaScript.<\/p>\n<p>UIWebView &#8211; UIKit | Apple Developer Documentation<br \/>\n<a href=\"https:\/\/developer.apple.com\/documentation\/uikit\/uiwebview\">https:\/\/developer.apple.com\/documentation\/uikit\/uiwebview<\/a><\/p><\/blockquote>\n<p>WKWebView\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u4f3c\u3066\u3044\u307e\u3059\u304c\u3001WebKit\u306e\u30a4\u30f3\u30dd\u30fc\u30c8\u3068\u3001HTML\u4e0a\u306e\u30ea\u30f3\u30af\u306e\u30af\u30ea\u30c3\u30af\u6642\u306e\u6319\u52d5\u3092\u5236\u5fa1\u3059\u308b\u305f\u3081\u306e\u30b3\u30fc\u30c9\u8a18\u8ff0\u3092\u8a73\u7d30\u306b\u884c\u308f\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3068\u3044\u3046\u70b9\u304c\u7570\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<figure class=\"jd-code\"><figcaption>FPAboutThisAppViewController.swift<\/figcaption><button type=\"button\" class=\"jd-code-copy\">\u30b3\u30d4\u30fc<\/button><pre><code class=\"language-swift\">import UIKit\r\nimport WebKit\r\n\r\nclass FPAboutThisAppViewController : UIViewController, WKNavigationDelegate {\r\n    \r\n    \r\n    override func viewDidLoad() {\r\n        super.viewDidLoad()\r\n        \r\n        \/\/\u30bf\u30a4\u30c8\u30eb\u8a2d\u5b9a\r\n        self.navigationItem.title = &quot;About Flash Photos&quot;\r\n        \r\n        \/\/View\u306e\u30b5\u30a4\u30ba\u53d6\u5f97\r\n        let webViewSize : CGRect = (self.navigationController?.view.frame)!\r\n        \r\n        \r\n        \/\/WKWebView\u521d\u671f\u5316\r\n        let aboutThisAppWebView : WKWebView = WKWebView(frame: webViewSize)\r\n        \r\n        \/\/navigationDelegate\u306e\u8a2d\u5b9a\r\n        aboutThisAppWebView.navigationDelegate = self\r\n        \r\n        \/\/WebView\u56de\u8ee2\u6642\u3082\u753b\u9762\u306bWebView\u3092\u5408\u308f\u305b\u308b\r\n        aboutThisAppWebView.autoresizingMask = UIViewAutoresizing(rawValue: UIViewAutoresizing.RawValue(UInt8(UIViewAutoresizing.flexibleWidth.rawValue) | UInt8(UIViewAutoresizing.flexibleHeight.rawValue)))\r\n        \r\n        \/\/AboutThisApp.html\u3078\u30a2\u30af\u30bb\u30b9\r\n        let fileUrl = Bundle.main.url(forResource: &quot;AboutThisApp&quot;, withExtension: &quot;html&quot;)\r\n        \r\n        \/\/AboutThisApp.html\u3078\u30a2\u30af\u30bb\u30b9\u3001\u8aad\u307f\u8fbc\u307f\r\n        let request : URLRequest = URLRequest.init(url: fileUrl!)\r\n        aboutThisAppWebView.load(request)\r\n        \r\n        \/\/webView\u3092\u8868\u793a\r\n        self.view.addSubview(aboutThisAppWebView)\r\n    }\r\n    \r\n    func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -&gt; Void) {\r\n        \r\n        \/\/\u30ea\u30f3\u30af\u304c\u62bc\u3055\u308c\u305f\u6642\r\n        if navigationAction.navigationType == .linkActivated {\r\n            \/\/\u30ea\u30f3\u30af\u5148\u3092Safari\u3067\u958b\u304f\r\n            UIApplication.shared.openURL(navigationAction.request.url!)\r\n            \/\/WKWebView\u3067\u306f\u958b\u304b\u306a\u3044\r\n            decisionHandler(.cancel)\r\n        } else {\r\n            \/\/\u305d\u308c\u4ee5\u5916\u306e\u30b1\u30fc\u30b9\u3067\u306fWKWebView\u3067\u30da\u30fc\u30b8\u3092\u958b\u304f\r\n            decisionHandler(.allow)\r\n        }\r\n    }\r\n}<\/code><\/pre><\/figure>\n<p>\u4e0a\u8a18\u30b3\u30fc\u30c9\u306b\u5909\u66f4\u3057\u305f\u5f8c\u306e\u6319\u52d5\u306e\u52d5\u753b\u3067\u3059\u3002iPhoneX\u306e\u5168\u753b\u9762\u3092\u4f7f\u7528\u3057\u3066HTML\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<div style=\"width: 960px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-248-1\" width=\"960\" height=\"540\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/10\/iphonex_wkwebview.mp4?_=1\" \/><a href=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/10\/iphonex_wkwebview.mp4\">https:\/\/jidouka.work\/wp-content\/uploads\/2017\/10\/iphonex_wkwebview.mp4<\/a><\/video><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u3088\u3053\u306d\u3063\u3068\u306e\u30a2\u30d7\u30ea\u3067\u3042\u308bFlash Photos\u306fAbout\u306e\u60c5\u5831\u306e\u8868\u793a\u306bUIWebView\u3092\u4f7f\u7528\u3057 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":250,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[14,15],"class_list":["post-248","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ios","tag-iphone","tag-swift"],"_links":{"self":[{"href":"https:\/\/jidouka.work\/index.php?rest_route=\/wp\/v2\/posts\/248","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jidouka.work\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jidouka.work\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jidouka.work\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jidouka.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=248"}],"version-history":[{"count":4,"href":"https:\/\/jidouka.work\/index.php?rest_route=\/wp\/v2\/posts\/248\/revisions"}],"predecessor-version":[{"id":255,"href":"https:\/\/jidouka.work\/index.php?rest_route=\/wp\/v2\/posts\/248\/revisions\/255"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jidouka.work\/index.php?rest_route=\/wp\/v2\/media\/250"}],"wp:attachment":[{"href":"https:\/\/jidouka.work\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jidouka.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jidouka.work\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}