<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kimi Peng on Medium]]></title>
        <description><![CDATA[Stories by Kimi Peng on Medium]]></description>
        <link>https://medium.com/@kimipon?source=rss-23d44cd9953b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BbNphkyx5sbNVhRG7pda_Q.jpeg</url>
            <title>Stories by Kimi Peng on Medium</title>
            <link>https://medium.com/@kimipon?source=rss-23d44cd9953b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 00:30:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kimipon/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Handle the web view communicate with Android via webkit.messageHandler postMessage.]]></title>
            <link>https://medium.com/@kimipon/handle-the-web-view-communicate-with-android-via-webkit-messagehandler-postmessage-67995b2444c?source=rss-23d44cd9953b------2</link>
            <guid isPermaLink="false">https://medium.com/p/67995b2444c</guid>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Kimi Peng]]></dc:creator>
            <pubDate>Fri, 24 Mar 2023 04:27:38 GMT</pubDate>
            <atom:updated>2023-03-24T04:27:38.035Z</atom:updated>
            <content:encoded><![CDATA[<h3>Receiving Javascript Messages</h3><p>webkit.messageHandler.callbackHandler.postMessage for iOS可參考<a href="https://medium.com/@sunry81914/postmessage-swift3-webview-%E8%88%87-javascript-%E9%9B%99%E5%90%91%E6%BA%9D%E9%80%9A%E7%9A%84%E6%A9%8B%E6%A8%91-c1d27a3da97f">postMessage() : Swift3 WebView 與 Javascript 雙向溝通的橋樑</a> 。</p><p>假設Android也要透過webkit.messageHandler.callbackHandler.postMessage(&#39;Hello iOS&#39;)的方法來收訊息，並說明如何實作。</p><p>Android上面，大多教我們宣告一個Interface。只要Android與前端共同定義就好。如下</p><pre>&lt;script&gt;<br>    btnSendMessage.addEventListener(&#39;click&#39;, () =&gt; {<br>          window.Medium.postMessage(&#39;Hello Medium&#39;);<br>          // Android.postMessage(&#39;Hello Medium&#39;);  // &lt;- 前端這樣寫也可以<br>    });      <br>&lt;/script&gt;</pre><p>Android就要宣告一個類別(JsObject)並定義方法與前端介面方法名稱相同，在方法前面加上@JavascriptInterface</p><p>初始App Webview就要加上addJavascriptInterface(JsonObject, InterfaceName)</p><pre>binding.webView.settings.javaScriptEnabled = true<br>binding.webView.settings.javaScriptCanOpenWindowsAutomatically = true<br>binding.webView.addJavascriptInterface(JsObjcet(), &quot;Medium&quot;)<br>binding.webView.loadUrl(&quot;http://mediumtest.html&quot;)</pre><pre>class JsObjcet {<br><br>      @JavascriptInterface<br>      fun postMessage(message: String) {<br>         // App Do something<br>      }<br><br>}</pre><p>前面都是一般的方法，教我們如何與收到前端Web的message。</p><p>過往前端的Javascript會有Android與iOS會有兩種postMessage方法並行的方式出現</p><pre>&lt;script&gt;<br>    button.addEventListener(&#39;click&#39;, () =&gt; {<br>          window.Medium.postMessage(&#39;Hello Medium&#39;);<br>          window.webkit.messageHandler.callbackHandler.postMessage(&#39;Hello Medium&#39;)<br>    });      <br>&lt;/script&gt;</pre><h3>But…</h3><p>Android其實<strong>可以</strong>透過window.webkit.messageHandler.callbackHandler.postMessage(&#39;Hello iOS&#39;)的方法來收訊息。實作WebViewClient並在onPageStarted執行evaluateJavascript</p><pre>&quot;window.webkit = { messageHandlers: { callbackHandler: window.Medium} }&quot;</pre><p>Example如下，</p><pre>webview.webViewClient = object : WebViewClient() {<br>    override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {<br>          super.onPageStarted(view, url, favicon)<br>          evaluateJavascript(&quot;window.webkit = { messageHandlers: { callbackHandler: window.Medium} }&quot;) {}<br>    }<br>}</pre><p>透過這個方法就可以與iOS實作相同收到訊息，而實務上不建議這樣的方法。</p><blockquote>IMO it’s a textbook “hack” and should be avoided. Unless you have full control over the pages you load, it could lead to bugs or pages breaking. You never know if a page uses window.webkit for something else.</blockquote><blockquote>Stackoverflow <a href="https://stackoverflow.com/users/9017295/torkel-velure">Torkel Velure</a></blockquote><p><a href="https://stackoverflow.com/questions/39744248/handle-webkit-messagehandler-postmessage-on-android">https://stackoverflow.com/questions/39744248/handle-webkit-messagehandler-postmessage-on-android</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67995b2444c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create Android aar file?]]></title>
            <link>https://medium.com/@kimipon/how-to-create-android-aar-file-6ab7efae9681?source=rss-23d44cd9953b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ab7efae9681</guid>
            <dc:creator><![CDATA[Kimi Peng]]></dc:creator>
            <pubDate>Wed, 21 Jul 2021 07:57:36 GMT</pubDate>
            <atom:updated>2021-07-21T07:57:36.770Z</atom:updated>
            <content:encoded><![CDATA[<p>開發筆記: 如何直接build Android aar file?</p><p>Github有許多高手發佈了很多好用的library。</p><p>但如何有一天停止更新發佈在maven repository 或是 jcenter deprecated，這時就要用aar來導入library。</p><ul><li>抓下Github相關的專案</li><li>打開Android Studio</li><li>在Gradle區塊下打開面版，選擇按下assembleRelease</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*3VVFQWw1Y2F4rSJjukSuoQ.png" /><figcaption>Android Studio 4.2.2畫面</figcaption></figure><ul><li>Build完以後，就可在build/outputs/aar 下看到剛剛build成功的aar</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*p2vEwR3RikkpEsluC9K1lQ.png" /><figcaption>build/outputs/aar/xxxxx.aar</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ab7efae9681" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[UIView note]]></title>
            <link>https://medium.com/@kimipon/uiview-note-620acb6ac2b?source=rss-23d44cd9953b------2</link>
            <guid isPermaLink="false">https://medium.com/p/620acb6ac2b</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Kimi Peng]]></dc:creator>
            <pubDate>Tue, 26 Nov 2019 10:08:26 GMT</pubDate>
            <atom:updated>2019-11-26T10:17:36.951Z</atom:updated>
            <content:encoded><![CDATA[<p>clipsToBounds屬性</p><p>學習線上課程時，因為經常用到此屬性。<br>課程也沒有特別講解此屬性用法，因此寫個note記錄一下。</p><blockquote>clipsToBounds</blockquote><p><a href="https://developer.apple.com/documentation/uikit/uiview/1622415-clipstobounds">clipsToBounds | Apple Developer Documentation</a></p><pre>A Boolean value that determines whether subviews are confined to the bounds of the view.</pre><p>簡單來說，在SuperView將clipsToBounds設置為<strong>true</strong>。<br>SubView就會修剪View的大小以符合SuperView的邊界。</p><p>設置為false，SubView則會超出SuperView。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=620acb6ac2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git Completion on macOS]]></title>
            <link>https://medium.com/@kimipon/git-completion-on-macos-24b6367baec5?source=rss-23d44cd9953b------2</link>
            <guid isPermaLink="false">https://medium.com/p/24b6367baec5</guid>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Kimi Peng]]></dc:creator>
            <pubDate>Thu, 10 Jan 2019 06:41:36 GMT</pubDate>
            <atom:updated>2019-01-10T06:41:36.882Z</atom:updated>
            <content:encoded><![CDATA[<p>記錄如何在macOS下新增自動補齊功能</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*-aMWfE6iQftLhWy1nCfe9A.png" /></figure><p>針對mac環境，做以下動作</p><pre>brew update<br>brew install bash-completion<br>brew reinstall git</pre><p>去Github將git source code clone下來，將git/contrib/completion/git-completion.bash複製到家目錄下。</p><pre>git clone https://github.com/git/git.git cp git/contrib/completion/git-completion.bash ~/.git-completion.bash</pre><p><a href="https://github.com/git/git.git">git/git</a></p><p>接著在Terminal下，執行以下指令。</p><pre>brew info bash-completion</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s-kBsBxzwxcLK44EGoaLQA.png" /><figcaption>msg</figcaption></figure><pre>vim ~/.bash_profile</pre><p>把紅框的文字加入bash_profile</p><pre>[ -f /usr/local/etc/bash_completion ] &amp;&amp; ./usr/local/etc/bash_completion  </pre><pre>source ~/.git-completion.bash</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9C12G4Z4Fy8vETlvz-e0Zw.png" /></figure><p>最後，在回到終端機下。</p><pre>source ~/.bash_profile</pre><p>當完成以上設定時，就可以在終端機有git 自動補齊的功能。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24b6367baec5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[研究CSS屬性 1]]></title>
            <link>https://medium.com/@kimipon/%E7%A0%94%E7%A9%B6css%E5%B1%AC%E6%80%A7-1-b8eba87680e4?source=rss-23d44cd9953b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8eba87680e4</guid>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Kimi Peng]]></dc:creator>
            <pubDate>Tue, 11 Dec 2018 08:38:23 GMT</pubDate>
            <atom:updated>2018-12-11T08:38:23.257Z</atom:updated>
            <content:encoded><![CDATA[<p>CSS屬性</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*ozFlxTZzClJeqZ6HeOdH9Q.png" /><figcaption><strong>Simple CSS</strong></figcaption></figure><blockquote>CSS屬性介紹</blockquote><ul><li>寬度 (單位: px)</li></ul><pre>width: 100px</pre><ul><li>高度(單位:px)</li></ul><pre>height: 100px</pre><ul><li>背景</li></ul><pre>background: red; 顏色直接表示</pre><pre>background: #800000; 十六進制表示</pre><pre>background: rgb(26, 122, 33); RGB表示</pre><ul><li>字體(單位:px)</li></ul><pre>font-size: 30px;</pre><ul><li>粗體大小</li></ul><pre>font-weight: 800</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*CAeQHuiqa41plx6ZzTxYCA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*2nnT_pnC-hSxTAC3VZbNGg.png" /><figcaption><strong>font-weight 200 V.S 800</strong></figcaption></figure><ul><li>字型樣式</li></ul><pre>font-style: italic</pre><p>樣式下有inherit、initial、italic、normal、oblique、unset。</p><ul><li>字型大小寫</li></ul><pre>font-variant: normal|small-caps|initial|inherit;</pre><p><a href="https://www.w3schools.com/cssref/pr_font_font-variant.asp">CSS font-variant property</a></p><p>In a small-caps font, all lowercase letters are converted to uppercase letters. However, the converted uppercase letters appears in a smaller font size than the original uppercase letters in the text.</p><ul><li>Text水平對齊方式</li></ul><pre>text-align: left|right|center|justify|initial|inherit;</pre><blockquote><em>Conclusion</em></blockquote><p>身為一個Mobile開發工程師，也要學習一下HTML相關知識。<br>這算是一個起步，記錄整理目前學習進度。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8eba87680e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[研究 navigation bar 的欄位]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/study-navigation-bar-e3858a34aace?source=rss-23d44cd9953b------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3858a34aace</guid>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Kimi Peng]]></dc:creator>
            <pubDate>Tue, 18 Sep 2018 06:24:33 GMT</pubDate>
            <atom:updated>2018-09-18T06:24:33.496Z</atom:updated>
            <content:encoded><![CDATA[<p>延續Navigation Bar研究</p><blockquote>Topic</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*6sigXbYbiakzwEHihhHN6Q.png" /><figcaption><a href="https://developer.apple.com/documentation/uikit/uinavigationbar">UINavigationBar</a></figcaption></figure><p>研究Navigation Bar相關屬性設定</p><p>以下就針對調整不同屬性來看區別在哪</p><blockquote>Navigation Bar</blockquote><p>1. Bar Tint</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*4g6WmDbSb0grMlN0mhWxMw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*KMuEdldgcAdKPzVLJULfyA.png" /><figcaption><strong>Bar Tint</strong></figcaption></figure><p>2. Translucent<br>這個屬性一開始看不出來，就參考<a href="http://twitter.com/chenky3890">@chenky3890</a>所寫的才晃然大悟區別在哪。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*n4fYehO_YbhjEpf6xdIdVw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*B1hC6WnW3maQK-hos6Igjw.png" /><figcaption><strong>設定Translucent</strong></figcaption></figure><blockquote>Title Text Attributes</blockquote><ol><li>Title Font</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*Nv_B63pbOeMKBJ9kjDaNfw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*Pf7QQIWPMjtdLwWpR445zw.png" /><figcaption><strong>Different Title Font</strong></figcaption></figure><p>2. Title Color</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*H-B7ASthe0cf-OAQxfrxhw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*8y6la7jh1nX_B1BNGwi2EA.png" /><figcaption><strong>設定Title Color</strong></figcaption></figure><blockquote>Conclusion</blockquote><p>本篇就簡略透過圖示來說明欄位來看區別在哪 :)</p><blockquote>Reference</blockquote><p><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/%E7%A0%94%E7%A9%B6-navigation-bar-%E7%9A%84%E6%AC%84%E4%BD%8D-f285850b5f70">研究 navigation bar 的欄位</a> — <a href="http://twitter.com/chenky3890">@chenky3890</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3858a34aace" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/study-navigation-bar-e3858a34aace">研究 navigation bar 的欄位</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[研究 Alamofire]]></title>
            <link>https://medium.com/@kimipon/study-alamofire-method-a2bbb1b97af5?source=rss-23d44cd9953b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2bbb1b97af5</guid>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Kimi Peng]]></dc:creator>
            <pubDate>Mon, 17 Sep 2018 10:32:40 GMT</pubDate>
            <atom:updated>2018-09-17T10:32:40.487Z</atom:updated>
            <content:encoded><![CDATA[<p>Data, Download, Upload Request</p><blockquote>Previous story</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*qkOCEhp5g9ixArBdLDwPyw.png" /></figure><p>在上一篇<a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/practice-use-alamofire-library-9ffc99a981b4">使用第三方套件Alamofire</a>只用到簡易的呼叫方法。</p><p>本篇稍微記錄學習Alamofire的用法，方便自已未來需要時在來翻翻這裡的筆記。</p><p>這邊搭配JSONPlaceholder來當做一個簡易後台。</p><p><a href="https://jsonplaceholder.typicode.com/">JSONPlaceholder</a></p><blockquote>使用情境</blockquote><p>當呼叫的後台api不需要帶任何參數時，直接用以下的方式就可以得到request後的結果。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d44148cef192831af1142ffb0ee7cdca/href">https://medium.com/media/d44148cef192831af1142ffb0ee7cdca/href</a></iframe><p>但在實際開發上，通常都會帶有參數。如下就是有參數的http request:</p><pre><a href="https://jsonplaceholder.typicode.com/comments?postId=1">https://jsonplaceholder.typicode.com/comments?postId=1</a></pre><p>所以在遇到需要帶有參數就要用下面的寫法來取得資料。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d67d8d01910833df9a613babfad3ba13/href">https://medium.com/media/d67d8d01910833df9a613babfad3ba13/href</a></iframe><p>另外我想HTTP POST method，也是與GET相同的呼叫方式。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*yvwJjUT1fljnJtr72IcJrQ.png" /><figcaption><strong>Http method [POST]</strong></figcaption></figure><blockquote>Others— Download &amp; Upload request</blockquote><p>Alamofire也同樣支援下載與上傳功能</p><ol><li><strong>Download request</strong></li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/30ee796c3c2faae77cbb070445bc06ed/href">https://medium.com/media/30ee796c3c2faae77cbb070445bc06ed/href</a></iframe><p>2. <strong>Upload Request</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/324162cc7e88bf0e61ffa858a6849eb3/href">https://medium.com/media/324162cc7e88bf0e61ffa858a6849eb3/href</a></iframe><blockquote>Conclusion</blockquote><p>未來開發上如果有不同的應用時，在上來做個記錄。<br>例如下載檔案時，需顯示目前的進度。</p><blockquote>Reference</blockquote><p><a href="https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%204.0%20Migration%20Guide.md">Alamofire 4.0 Migration Guide</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2bbb1b97af5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[使用第三方套件Alamofire與實作下拉更新(Pull to Refresh)]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/practice-use-alamofire-library-9ffc99a981b4?source=rss-23d44cd9953b------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ffc99a981b4</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Kimi Peng]]></dc:creator>
            <pubDate>Sun, 16 Sep 2018 04:34:41 GMT</pubDate>
            <atom:updated>2018-09-16T04:34:41.845Z</atom:updated>
            <content:encoded><![CDATA[<p>iOS App練習串接第三方API #2</p><blockquote>觀察</blockquote><p>點進在Github上的Alamofire，馬上就看到下面這句。</p><pre>Elegant HTTP Networking in Swift</pre><p>Alamofire is an HTTP networking library written in Swift.</p><p><a href="https://github.com/Alamofire/Alamofire">GitHub - Alamofire/Alamofire: Elegant HTTP Networking in Swift</a></p><blockquote>How to use?</blockquote><p>只要先透過Pods install Alamofire，僅僅透過下面這樣就可以簡單呼叫Api</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d44148cef192831af1142ffb0ee7cdca/href">https://medium.com/media/d44148cef192831af1142ffb0ee7cdca/href</a></iframe><blockquote>實作Alamofire</blockquote><p>延續上一篇<a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/call-the-open-data-6a44185c264">iOS App練習串接第三方API #1</a>，本篇就以空氣品質指標(AQI)來做資料呈現並搭配第三方套件Alamofire。</p><p>需要以下圖”response.data”，才是Server回傳的資料。也是一樣透過JSONDecoder才可將JSON資料轉成dictionary。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*HaZktqeXUHjmXv0hFbjemw.png" /><figcaption><strong>Simple Http Request by Alamofire 4</strong></figcaption></figure><p>其它部份畫面實作(如TabViewController)與<a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/call-the-open-data-6a44185c264">上一篇</a>相同，僅在http request採用不同的方法。有第三方套件幫忙是相當有力的可避免重覆刻輪子的情形發生。</p><p>另外，Alamofire在本篇僅以較簡單的方式實作。後續在來研究進階的用法，如POST…等其它HTTP method。</p><blockquote>實作Pull to Refresh</blockquote><p>如果只是實作Alamofire，好像有點簡單。<br>所以也順便加入下拉更新，而TableViewControl本身在super class就有refreshControl屬性。</p><p>因此只要去生成物件，並設相關方法即可。值得一提的是在addTarget方法中action，需要自行實作refresh method的內容。因為目的是重新執行一次http request，所以在refresh方法內呼叫reuqestHttpData。</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e666da2eac9be9718d7a1e7e95748866/href">https://medium.com/media/e666da2eac9be9718d7a1e7e95748866/href</a></iframe><p>另外，也可用拉@IBActon的方式做到相同的效果。如@<a href="https://medium.com/@shinyshih?source=post_header_lockup">Shiny Shih</a> <a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/%E7%AD%86%E8%A8%98-tableview-refresh%E8%88%87footer-46c910189075">#筆記 — tableView refresh與footer</a>這篇的方式做到下拉更新的方式。</p><blockquote>實機畫面</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/243/1*nvv0bqRibuZl65I4NrcvfQ.gif" /><figcaption><strong>Alamofire &amp; Pull-to- refresh</strong></figcaption></figure><blockquote>Conclusion</blockquote><p>本篇主要在講Alamofire的簡易使用，及實作下拉更新。</p><p>程式碼部份也有closure練習。針對當不同情況下執行完httpRequest後，更新UI畫面。</p><blockquote>Source Code</blockquote><p><a href="https://github.com/shinhua/OpenDataGov">shinhua/OpenDataGov</a></p><blockquote>Reference</blockquote><ol><li><a href="http://twitter.com/apppeterpan">@apppeterpan</a> <a href="https://medium.com/@apppeterpan/collection-view-scroll-view-table-view%E5%9C%A8ios-10%E9%83%BD%E8%88%87%E7%94%9F%E4%BF%B1%E4%BE%86%E6%94%AF%E6%8F%B4%E4%B8%8B%E6%8B%89%E6%9B%B4%E6%96%B0%E4%BA%86-1f40e3b1d097">Collection View, Scroll View, Table View在iOS 10都與生俱來支援下拉更新了 !</a></li><li>@<a href="https://medium.com/@shinyshih?source=post_header_lockup">Shiny Shih</a> <a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E6%95%99%E5%AE%A4/%E7%AD%86%E8%A8%98-tableview-refresh%E8%88%87footer-46c910189075">#筆記 — tableView refresh與footer</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ffc99a981b4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/practice-use-alamofire-library-9ffc99a981b4">使用第三方套件Alamofire與實作下拉更新(Pull to Refresh)</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS App練習串接第三方API #1]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/call-the-open-data-6a44185c264?source=rss-23d44cd9953b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a44185c264</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Kimi Peng]]></dc:creator>
            <pubDate>Fri, 14 Sep 2018 08:52:33 GMT</pubDate>
            <atom:updated>2018-09-14T13:53:58.911Z</atom:updated>
            <content:encoded><![CDATA[<p>取得Open Data來做資料呈現</p><blockquote><strong>發想</strong></blockquote><p>身為一個土木系畢業生，來做點與環境相關的App。</p><blockquote><strong>找資料</strong></blockquote><p>大多人都有做過氣象資料相關串接，所以我就選點比較不一樣的來做資料呈現。<br>首先去<a href="https://opendata.epa.gov.tw/">環境資源資料開放平臺</a>，找尋與環境相關的開放資料。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*_WtEIomb4EoISJuCBLqpGw.png" /><figcaption><strong>OpenData.epa</strong></figcaption></figure><p>選了以下兩種來做資料呈現，</p><pre>紫外線即時監測<em>: <br></em><a href="https://opendata.epa.gov.tw/ws/Data/UV/?$format=json">https://opendata.epa.gov.tw/ws/Data/UV/?$format=json</a></pre><pre>空氣品質指標(AQI): <br><a href="https://opendata.epa.gov.tw/ws/Data/AQI/?$format=json">https://opendata.epa.gov.tw/ws/Data/AQI/?$format=json</a></pre><blockquote><strong>實作</strong></blockquote><p>因為資料回傳是JSON格式，所以針對UVI來做資料呈現。</p><p>在Xcode上新增一個叫UVI.swift的檔案，並定義一個struct相關內容。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/1*7_duk_VTh4QmFR424XOdcQ.png" /><figcaption><strong>Request UVI return data format</strong></figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c3389746db6e97d1c31a371e910d760/href">https://medium.com/media/8c3389746db6e97d1c31a371e910d760/href</a></iframe><p>接著新增一個UVITableViewController.swift來實作資料呈現，這邊就用課程中所教的</p><ol><li>利用URLSession做Http request</li><li>Parse資料使用JSONDecoder來處理</li></ol><p>另外，我個人在實作中常常找不到&amp;忘記需要在storyboard，針對TabCell去做identifier。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iTYpxtqkME_EMAY_n4RAAw.png" /></figure><blockquote>為什麼需要去定義identifier，它重要嗎?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AKf8Kf3UbCqLfZWMK8A6kw.png" /><figcaption><strong>tableView.dequeueReusableCell</strong></figcaption></figure><p>紅框內identifier，需與TableCell一致。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*g6g1OqGlNXlk37HESCuV7A.png" /><figcaption><strong>identifier</strong></figcaption></figure><p>而定義成常數項，主要避免手殘打錯。</p><p>以上是實作中遇到的小問題。</p><blockquote>實機畫面</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/243/1*Au1wcir-KALu9jAICVkW-w.gif" /><figcaption><strong>資料呈現</strong></figcaption></figure><blockquote>小結</blockquote><p>紫外線即時監測資料是採用URLSession，之後空氣品質指標(AQI)則會搭配第三方套件來做Http Request。</p><blockquote>Source Code in GitHub</blockquote><p><a href="https://github.com/shinhua/OpenDataGov">shinhua/OpenDataGov</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a44185c264" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/call-the-open-data-6a44185c264">iOS App練習串接第三方API #1</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[跟著彼得潘學習Swift心得歷程]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/%E5%AD%B8%E7%BF%92swift%E5%BF%83%E5%BE%97%E6%AD%B7%E7%A8%8B-d4377f73a355?source=rss-23d44cd9953b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4377f73a355</guid>
            <dc:creator><![CDATA[Kimi Peng]]></dc:creator>
            <pubDate>Thu, 13 Sep 2018 06:48:47 GMT</pubDate>
            <atom:updated>2018-09-13T09:55:44.868Z</atom:updated>
            <content:encoded><![CDATA[<p>跟著彼得潘學習iOS App開發心得歷程</p><blockquote>前言</blockquote><p>一開始想說自學Objective-C來拓展同時在<strong>iOS</strong>與<strong>Android</strong>開發，但後來發現Objective-C並不是那麼容易上手。加上有些開發資訊可能很久了，轉而來學習Swift。</p><p>後來也跟著Apple官網<a href="https://developer.apple.com/library/archive/referencelibrary/GettingStarted/DevelopiOSAppsSwift/BuildABasicUI.html#//apple_ref/doc/uid/TP40015214-CH5-SW1">Start Developing iOS Apps (Swift)</a>來實作一個app，雖然跟著官網步驟也可以完成。</p><p>但內心就是覺得少了一種踏實感，我發現我對swift跟本不是那麼了解。只能依過往學習Android的經驗來擬定學習計畫，我真的需要一本可以教我swift的工具書。</p><blockquote>轉折</blockquote><p>於是在天瓏書局就順手翻了幾本有關iOS開發的書。<br>題外話以我在Android學習的經驗千萬別在一開始就看”幾x天學會某某語言”、”快速學習某某語言高手”。<br>(這類書不是說不好，只是它不是那麼適合初學者)。</p><blockquote>就像武俠小說一樣，<strong>學武功馬步要紮好</strong>後面才學得快。</blockquote><p>保持著這個信念就在架上看到一本相當醒目的橘皮書，裡面的教學內容也是很容易理解。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/263/1*kJPLWjWOadLjplB1O5SG0w.png" /><figcaption><strong>Swift基礎內功手冊</strong></figcaption></figure><blockquote>起點</blockquote><p>研讀了一陣子，覺得還是離實際開發還是不夠。</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FIp0hG7FXVgs%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DIp0hG7FXVgs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FIp0hG7FXVgs%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7631296379a3af8e14be430ff689098/href">https://medium.com/media/c7631296379a3af8e14be430ff689098/href</a></iframe><p>因為很習慣彼得書上教學，加上彼得又有開課<a href="http://peterpaniosapp.strikingly.com/">http://peterpaniosapp.strikingly.com/</a></p><p>於是就這樣開始我的iOS開發學習之路。</p><blockquote>過程</blockquote><p>彼得潘上課還蠻有趣的，加上我感覺他在整體課程教學上有個隱含不錯的概念。</p><blockquote><strong>持續不斷地</strong>不斷地<strong>練習…</strong></blockquote><p>彼得會在課程中出大量(超多!!)的作業讓初學者練習，<br>即便現在課程結束，我也是在寫之前未寫完的作業。XD</p><p>但是從練習可以清楚知道身為一個iOS開發者需要具備該怎麼樣基礎能力。ex: 熟悉Xcode介面、現行開發團隊所使用工具…等。</p><blockquote>結論</blockquote><p>最重要的一點與未來想學iOS的朋友分享。</p><blockquote>彼得潘他是一個像領航員般的朋友，帶初學者走進iOS開發世界。但後續開發還是要大量練習才能掌握這技術。</blockquote><p>來學習吧，彼得潘人很Nice的!<br>P.S. 程式寫不好也沒關係，彼得也會教怎麼當一個文青。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4377f73a355" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/%E5%AD%B8%E7%BF%92swift%E5%BF%83%E5%BE%97%E6%AD%B7%E7%A8%8B-d4377f73a355">跟著彼得潘學習Swift心得歷程</a> was originally published in <a href="https://medium.com/peter-pan-swift-ios-class">彼得潘的 Swift iOS / Flutter App 開發教室</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>