{"id":4721,"date":"2017-12-08T23:55:28","date_gmt":"2017-12-08T14:55:28","guid":{"rendered":"https:\/\/ukaapple.selfip.com\/support\/?p=4721"},"modified":"2017-12-09T00:13:24","modified_gmt":"2017-12-08T15:13:24","slug":"original_app_56","status":"publish","type":"post","link":"https:\/\/minnano.app\/support\/2017\/12\/08\/original_app_56\/","title":{"rendered":"\u72ec\u5275\u30a2\u30d7\u30ea\u958b\u767a\u65e5\u8a18 56\u65e5\u76ee \u30d7\u30ed\u30b0\u30ec\u30b9\u30d0\u30fc"},"content":{"rendered":"<p>\u4eca\u65e5\u306f\u3001\u6628\u65e5\u306e\u7d9a\u304d\u3067\u30d7\u30ed\u30b0\u30ec\u30b9\u30d0\u30fc\u306e\u8868\u793a\u5bfe\u5fdc\u3067\u3059\u3002<\/p>\n<p>\u4ee5\u4e0bViewController.swift\u306e\u30b3\u30fc\u30c9\u3067\u3059\u3002\u753b\u9762\u306e\u4e0b\u7aef\u306b\u8868\u793a\u3057\u307e\u3057\u305f\u3002\u30da\u30fc\u30b8\u8aad\u307f\u8fbc\u307f\u958b\u59cb\u6642\u306f\u30aa\u30ec\u30f3\u30b8\u8272\u3067\u3001\u8aad\u307f\u8fbc\u3080\u3068\u5171\u306b\u7dd1\u8272\u306b\u306a\u3063\u3066\u884c\u304d\u307e\u3059\u3002<\/p>\n<pre><code>\r\nimport UIKit\r\nimport WebKit\r\n\r\nclass ViewController: UIViewController {\r\n\r\n    private var _webView : WKWebView!\r\n    private var _hideStatusBar : Bool = false\r\n    private var _iPhoneX_Header : CGFloat = 0\r\n    private var _progressView: UIProgressView!\r\n    \r\n    func iPhoneX() -> Bool {\r\n        guard #available(iOS 11.0, *) else {\r\n            return false\r\n        }\r\n        return UIApplication.shared.windows[0].safeAreaInsets != UIEdgeInsets.zero\r\n    }\r\n    \r\n    override func viewDidLoad() {\r\n        super.viewDidLoad()\r\n        \/\/ Do any additional setup after loading the view, typically from a nib.\r\n        \/\/ \u30b9\u30c6\u30fc\u30bf\u30b9\u30d0\u30fc\u306e\u9ad8\u3055\u3092\u53d6\u5f97\r\n        _iPhoneX_Header = iPhoneX() ? UIApplication.shared.statusBarFrame.size.height : 0\r\n        \/\/ WKWebView\u3092\u4f4d\u7f6e\u6307\u5b9a\u3057\u3066\u8868\u793a\r\n        _webView = WKWebView(frame:CGRect(x:0, y: -_iPhoneX_Header, width:self.view.bounds.size.width, height:self.view.bounds.size.height + _iPhoneX_Header))\r\n        \/\/ \u30b8\u30a7\u30b9\u30c1\u30e3\u30fc(\u30d5\u30ea\u30c3\u30af)\u306b\u3088\u308b \u9032\u3080 \u3084 \u623b\u308b \u3092\u8a31\u53ef\r\n        _webView.allowsBackForwardNavigationGestures = true\r\n        \/\/ WebView\u306e\u8aad\u8fbc\u76e3\u8996\r\n        _webView.addObserver(self, forKeyPath:\"estimatedProgress\", options:.new, context:nil)\r\n        \/\/ \u30b9\u30c6\u30fc\u30bf\u30b9\u30d0\u30fc\u306e\u975e\u8868\u793a \u203b\u30b9\u30c6\u30fc\u30bf\u30b9\u30d0\u30fc\u306e\u9ad8\u3055\u3092\u53d6\u5f97\u3059\u308b\u524d\u306b\u975e\u8868\u793a\u306b\u3059\u308b\u3068\u3001\u30b9\u30c6\u30fc\u30bf\u30b9\u30d0\u30fc\u306e\u9ad8\u3055\u304c\u53d6\u5f97\u3067\u304d\u306a\u3044\r\n        _hideStatusBar = true\r\n        self.setNeedsStatusBarAppearanceUpdate()\r\n        \/\/ \u30c6\u30ad\u30b9\u30c8\u6f2b\u753b\u8aad\u307f\u8fbc\u307f\r\n        let url : URL = URL(string: \"https:\/\/minnano.app\/textmanga\/\")!\r\n        let request : URLRequest = URLRequest(url: url)\r\n        _webView.load(request)\r\n        self.view.addSubview(_webView)\r\n        \/\/ ProgressView\r\n        _progressView = UIProgressView(frame: CGRect(x:0, y:0, width:self.view.bounds.size.width * 2, height:4))\r\n        _progressView.layer.position = CGPoint(x:0, y:self.view.bounds.size.height - 1)\r\n        _progressView.transform = CGAffineTransform(scaleX: 1.0, y: 2.0)\r\n        _progressView.progressTintColor = UIColor.green\r\n        _progressView.trackTintColor = UIColor.orange\r\n        self.view.addSubview(_progressView)\r\n        \/\/ \u56de\u8ee2\u6642\u306e\u901a\u77e5\r\n        NotificationCenter.default.addObserver(self, selector: #selector(ViewController.orientationChange(notification:)), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)\r\n    }\r\n    deinit {\r\n        _webView?.removeObserver(self, forKeyPath: \"estimatedProgress\")\r\n    }\r\n    \r\n    @objc\r\n    private func orientationChange(notification: NSNotification) {\r\n        let portrait : Bool = UIInterfaceOrientationIsPortrait(UIApplication.shared.statusBarOrientation)\r\n        \/\/ WebView\u306e\u8868\u793a\u8abf\u6574\r\n        _webView.frame.origin = CGPoint(x:portrait ? 0 : -_iPhoneX_Header, y:portrait ? -_iPhoneX_Header : 0)\r\n        _webView.frame.size = CGSize(width:self.view.bounds.size.width + (portrait ? 0 : _iPhoneX_Header * 2), height:self.view.bounds.size.height + (portrait ? _iPhoneX_Header : 0))\r\n        \/\/ \u30d7\u30ed\u30b0\u30ec\u30b9\u30d0\u30fc\u306e\u8868\u793a\u8abf\u6574\r\n        _progressView.frame.origin = CGPoint(x: 0, y: 0)\r\n        _progressView.frame.size = CGSize(width:self.view.bounds.size.width * 2, height:4)\r\n        _progressView.layer.position = CGPoint(x:0, y:self.view.bounds.size.height - 1)\r\n    }\r\n    \r\n    \/\/ \u30b9\u30c6\u30fc\u30bf\u30b9\u30d0\u30fc\u306e\u975e\u8868\u793a\r\n    override var prefersStatusBarHidden: Bool {\r\n        return _hideStatusBar\r\n    }\r\n    \r\n    \/\/ WebView\u306e\u76e3\u8996\r\n    override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?) {\r\n        if(\"estimatedProgress\" == keyPath){\r\n            if(_progressView != nil){\r\n                \/\/ \u66f4\u65b0\r\n                let progress : Float = Float(_webView.estimatedProgress)\r\n                _progressView.setProgress(progress < 1.0 ? progress : 0.0, animated: true)\r\n                _progressView.alpha = progress < 1.0 ? 1.0 : 0.0  \/\/ \u8aad\u307f\u8fbc\u307f\u304c\u5b8c\u4e86\u3057\u305f\u3089\u975e\u8868\u793a\u306b\r\n            }\r\n        }\r\n    }\r\n    \r\n    override func didReceiveMemoryWarning() {\r\n        super.didReceiveMemoryWarning()\r\n        \/\/ Dispose of any resources that can be recreated.\r\n    }\r\n\r\n}\r\n<\/code><\/pre>\n<p>iPhoneX\u306e\u5168\u9762\u8868\u793a\u3084\u753b\u9762\u306e\u56de\u8ee2\u306b\u3082\u5bfe\u5fdc\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30c6\u30ad\u30b9\u30c8\u6f2b\u753b\u306f\u305d\u306e\u540d\u306e\u901a\u308a\u30c6\u30ad\u30b9\u30c8\u3070\u304b\u308a\u3067\u8aad\u307f\u8fbc\u307f\u65e9\u3044\u304b\u3089\u3001<\/p>\n<p style=\"font-size:xx-large\">\u305b\u3063\u304b\u304f\u4f5c\u3063\u305f\u3051\u3069\u30d7\u30ed\u30b0\u30ec\u30b9\u30d0\u30fc\u306f\u8981\u3089\u306a\u3044\u304b\u306a\u3041\u30fb\u30fb\u30fb<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u65e5\u306f\u3001\u6628\u65e5\u306e\u7d9a\u304d\u3067\u30d7\u30ed\u30b0\u30ec\u30b9\u30d0\u30fc\u306e\u8868\u793a\u5bfe\u5fdc\u3067\u3059\u3002 \u4ee5\u4e0bViewController.swift\u306e\u30b3\u30fc\u30c9\u3067\u3059\u3002\u753b\u9762\u306e\u4e0b\u7aef\u306b\u8868\u793a\u3057\u307e\u3057\u305f\u3002\u30da\u30fc\u30b8\u8aad\u307f\u8fbc\u307f\u958b\u59cb\u6642\u306f\u30aa\u30ec\u30f3\u30b8\u8272\u3067\u3001\u8aad\u307f\u8fbc\u3080\u3068\u5171\u306b\u7dd1\u8272\u306b\u306a\u3063\u3066\u884c\u304d\u307e\u3059\u3002 impor &hellip; <a href=\"https:\/\/minnano.app\/support\/2017\/12\/08\/original_app_56\/\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">\u72ec\u5275\u30a2\u30d7\u30ea\u958b\u767a\u65e5\u8a18 56\u65e5\u76ee \u30d7\u30ed\u30b0\u30ec\u30b9\u30d0\u30fc<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-4721","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/minnano.app\/support\/wp-json\/wp\/v2\/posts\/4721","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/minnano.app\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/minnano.app\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/minnano.app\/support\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/minnano.app\/support\/wp-json\/wp\/v2\/comments?post=4721"}],"version-history":[{"count":6,"href":"https:\/\/minnano.app\/support\/wp-json\/wp\/v2\/posts\/4721\/revisions"}],"predecessor-version":[{"id":4727,"href":"https:\/\/minnano.app\/support\/wp-json\/wp\/v2\/posts\/4721\/revisions\/4727"}],"wp:attachment":[{"href":"https:\/\/minnano.app\/support\/wp-json\/wp\/v2\/media?parent=4721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/minnano.app\/support\/wp-json\/wp\/v2\/categories?post=4721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/minnano.app\/support\/wp-json\/wp\/v2\/tags?post=4721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}