<?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 Siao Sian Huang on Medium]]></title>
        <description><![CDATA[Stories by Siao Sian Huang on Medium]]></description>
        <link>https://medium.com/@siaosianhuang?source=rss-e73650a33d28------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*4Ae9zXOKP2ioyWhb</url>
            <title>Stories by Siao Sian Huang on Medium</title>
            <link>https://medium.com/@siaosianhuang?source=rss-e73650a33d28------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 01:45:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@siaosianhuang/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[Swift 課後分享]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/swift-%E8%AA%B2%E5%BE%8C%E5%88%86%E4%BA%AB-aeaa5e27e6d7?source=rss-e73650a33d28------2</link>
            <guid isPermaLink="false">https://medium.com/p/aeaa5e27e6d7</guid>
            <dc:creator><![CDATA[Siao Sian Huang]]></dc:creator>
            <pubDate>Sat, 08 Sep 2018 09:13:39 GMT</pubDate>
            <atom:updated>2018-09-08T09:13:39.544Z</atom:updated>
            <content:encoded><![CDATA[<p>隨著彼德潘app的課程結束已經過去一個星期多。每每看到桌上的mac和畫面中寫到一半的程式時，心裡還是會時不時的跳出疑問。選這條路真的對嗎？</p><p>話說，會進入程式的行也是發生的很突然。雖然原本還算有點興趣，也曾在十年前就花了一大筆錢去學過java(講到這裡，彼德潘app的課程真的佛心無比，cp值之高真的會嚇死人)，但後來找工作無不是需要有經驗的。當下真的覺得「什麼情況！？沒經驗真的該死就是了啦！！！」，無比的心灰意冷。之後雖然一不小心也進了所謂的科技業，但工作的內容也一直用不太到之前所學的。而這樣的生活，也的確讓我一度以為這輩子大概真的和程式無緣了。</p><p>誰知道，幾年過後，突然有個機會來到我的面前。是一家新創公司，原本負責軟體的人年事已高(XD)想找個人來接替，所以就這樣莫名奇妙的開始了程式人生。</p><p>當然，沒經驗+英文不好(淚)的新手村生活真的不是一般人能想像。寫程式寫到第二天早上，回去睡到中午，下午再接著寫，然後又看到隔天的太陽。這種日子在每次機台出機前都會遇到，而且最少是一個星期以上。每每在那當下真的覺得一死百了算了(誤)，但卻也因為在這段時間裡一次又一次地意外寫出來(真的是不小心&quot;試&quot;出來的，連想找個人問都找不到)，才又有了堅持下去的力量。</p><p>上面說了一大堆，各位看官一定覺得&quot;關我屁事&quot;對吧XD。讓小弟來幫大家畫一下重點好了。</p><p>第1，當然是課程的價格了。因為不太了解現在外面學app的收費，所以只能和十年前學java時的價格相比了。十年前，曾在已倒閉的學承補過java，印象中是將近十萬。所以，當知道彼德潘的收費標準後，其實曾懷疑是不是詐騙集團來著的(XD)。但後來在google上隨便查了幾個關鍵字後，發現評價意外的高阿!!!所以才抱著「不貴，評價又高，信他一次好了!!」的心態付了錢(笑)</p><p>第2，自學不是不行。但如果有人個可以有系統的教你，再加上不分日夜的專人解惑，這真的是自學沒辦法享受的福利。在網路上查彼德潘時，會發現一個有趣的現像，就是大家對他上課的方式評價還蠻一致的，搞笑。這上起課來可以在一個相對放鬆的心情中學會怎麼做出一個app，而對被拿來當範例的同學而言，更是會大大的加深印象。</p><p>第3，解惑。彼德潘在第一堂課的時候，就曾經很臭屁的說：「從來沒有人可以把我出的作業寫完」。當下只覺得，這老師效果一定要做成這樣嗎？一定要這麼口出狂言！？那我要來當第一個把作業都寫完的人XD</p><p>但，小弟我事後發現我錯了，錯大了！！！他真的拼了命的出作業，沒人寫的完的啦(誤XD)！！雖然作業的數量真的太瘋狂了，但曾有過在新手村的經驗，所以也深信作業是真的有幫助。一來不但可以加深印象，二來真的實作了才知道自已的問題在那裡，以便更快速的認清自已有沒有把上課時所教的東西完全的吸收。</p><p>所以，<strong><em>寫作業真的非常非常非常的重要</em></strong>，每當你成功的完成了作業，不但會獲得大大的成就感，更可以用這些作業告訴(騙)自已，讓自已在這條不歸路可以走的更遠一點。所以還是要選擇拼命的完成作業，但新手嘛，過程中一定會發現有千百個的不懂，當那些的&quot;不懂&quot;把自已搞的欲仙欲死的時候，才知道原來在寫程式的過程中卡關了，有人可以求救是一件多幸福的事。</p><p>最後，在經過這兩個月上課的期間，其實自已還蠻慶興當初沒有真的把彼德潘當做詐騙集團的(哈哈哈…)。</p><p>雖然我不知道我什麼時候可以依靠這份能力混口飯吃，但我還在這條路上努力著。</p><p>和一樣是在這條不歸路上的大家共勉之!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aeaa5e27e6d7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/swift-%E8%AA%B2%E5%BE%8C%E5%88%86%E4%BA%AB-aeaa5e27e6d7">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>
        <item>
            <title><![CDATA[串接第三方api]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/%E4%B8%B2%E6%8E%A5%E7%AC%AC%E4%B8%89%E6%96%B9api-1e24fac0a583?source=rss-e73650a33d28------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e24fac0a583</guid>
            <dc:creator><![CDATA[Siao Sian Huang]]></dc:creator>
            <pubDate>Wed, 22 Aug 2018 06:01:26 GMT</pubDate>
            <atom:updated>2018-08-22T06:01:26.046Z</atom:updated>
            <content:encoded><![CDATA[<p>作業目的: 學習利用 URLSession 抓取後台的 JSON 資料後，利用 JSONDecoder 和 JSONSerialization 解析資料。</p><p>串接第三方 API，解析回傳的 JSON 資料，顯示成列表。點選列表的某個項目後，進到下一頁顯示詳細資訊。而地圖的部份是使用MapKit，這段function也是直接從書上抓來用的。使用方法則是傳入地址，則會依地圖顯示出所查到的位置。(好像也會有查不到的時候)</p><p>地圖相關程式：</p><pre><strong>func</strong> configure(location: String) {</pre><pre><em>//取得位置</em></pre><pre><strong>let</strong> geoCoder = CLGeocoder()</pre><pre>print(location)</pre><pre>geoCoder.geocodeAddressString(location, completionHandler: { placemarks, error <strong>in</strong></pre><pre><strong>if</strong> <strong>let</strong> error = error {</pre><pre>print(error.localizedDescription)</pre><pre><strong>return</strong></pre><pre>}</pre><pre><strong>if</strong> <strong>let</strong> placemarks = placemarks {</pre><pre><em>//取得第一個地點標記</em></pre><pre><strong>let</strong> placemark = placemarks[0]</pre><pre><em>//加上標記</em></pre><pre><strong>let</strong> annotation = MKPointAnnotation()</pre><pre><strong>if</strong> <strong>let</strong> location = placemark.location {</pre><pre>annotation.coordinate = location.coordinate</pre><pre><strong>self</strong>.DetailMap.addAnnotation(annotation)</pre><pre><em>//設定縮放程度</em></pre><pre><strong>let</strong> region = MKCoordinateRegion(center: annotation.coordinate, latitudinalMeters: 250, longitudinalMeters: 250)</pre><pre><strong>self</strong>.DetailMap.setRegion(region, animated: <strong>false</strong>)</pre><pre>}</pre><pre>}</pre><pre>})</pre><pre>}</pre><p>範例中使用的是桃園市政府公共停車場的資訊</p><p>JSON連結如下：</p><p><a href="https://data.tycg.gov.tw/opendata/datalist/datasetMeta/download?id=f4cc0b12-86ac-40f9-8745-885bddc18f79&amp;rid=0daad6e6-0632-44f5-bd25-5e1de1e9146f">https://data.tycg.gov.tw/opendata/datalist/datasetMeta/download?id=f4cc0b12-86ac-40f9-8745-885bddc18f79&amp;rid=0daad6e6-0632-44f5-bd25-5e1de1e9146f</a></p><p>第一頁是直接把抓到的資料分別顯示在cell裡，第二頁則會將第一頁所選的位置直接秀在地圖上。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CQfGDlnFOzwCVAMdrYbDNA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z28NzHfOsCZLiznE17drJw.png" /></figure><p>實機操作：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*8MN6dSWOSdHfDZGlDUBhPw.gif" /></figure><p>GitHub：</p><p><a href="https://github.com/Daniel579/ParkingAreaForJSON">Daniel579/ParkingAreaForJSON</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e24fac0a583" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/%E4%B8%B2%E6%8E%A5%E7%AC%AC%E4%B8%89%E6%96%B9api-1e24fac0a583">串接第三方api</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[Auto Layout]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/auto-layout-16249e113a80?source=rss-e73650a33d28------2</link>
            <guid isPermaLink="false">https://medium.com/p/16249e113a80</guid>
            <dc:creator><![CDATA[Siao Sian Huang]]></dc:creator>
            <pubDate>Sun, 19 Aug 2018 05:14:21 GMT</pubDate>
            <atom:updated>2018-08-19T05:14:21.005Z</atom:updated>
            <content:encoded><![CDATA[<p>這次重點是在Auto Layout，所以程式的部份則沒有實作喲！</p><p>先秀不同型號的iPhone開app時的樣子。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*MAmsDa9jOeUk7yhFotdjiA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*DExvmMKiS05VzZHJbvLFwg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*OalnhtkhJmfQwALVfXSdAA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*SUazyx8x9MooRNpFpH4JJA.png" /></figure><p>基本上，一開始就是先將所有的按鈕都拉到位。這部份要注意的是，因為各類型的尺寸不同，所以按鈕的大小要注意一下。可以先以最小尺寸的iPhone的樣式去訂定按鈕，以避免按鈕太大的情況發生。</p><p>再來，就以橫排為一組，先把每個橫排中的四個按鈕先包成stack view。再接著將這些stack view整個再包成一個stack view。</p><p>其中比較特別的是按鈕&quot;0&quot;的大小。要將0的邊界設成和2的邊界一樣。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*h2BWxUeEon9UABBR5edqAA.png" /></figure><p>這樣在不一樣寬的iPhone上時才會自動調整自已的寬度。</p><p>GitHub:</p><p><a href="https://github.com/Daniel579/Count">Daniel579/Count</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16249e113a80" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/auto-layout-16249e113a80">Auto Layout</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[二十一點亞洲慈善撲克王大賽]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/%E4%BA%8C%E5%8D%81%E4%B8%80%E9%BB%9E%E4%BA%9E%E6%B4%B2%E6%85%88%E5%96%84%E6%92%B2%E5%85%8B%E7%8E%8B%E5%A4%A7%E8%B3%BD-94375240fa70?source=rss-e73650a33d28------2</link>
            <guid isPermaLink="false">https://medium.com/p/94375240fa70</guid>
            <dc:creator><![CDATA[Siao Sian Huang]]></dc:creator>
            <pubDate>Sun, 12 Aug 2018 16:19:34 GMT</pubDate>
            <atom:updated>2018-08-12T16:19:34.108Z</atom:updated>
            <content:encoded><![CDATA[<p>原本想說來挑戰一下連線版的，沒想到查了一下資料一看，直接一個頭兩個大QQ</p><p>後來想說那做到最簡單的就好，把21點的規則弄出來先。結果在寫的過程中，又想說：「疑，這邊是不是可以未了之後連線版的時候先處理一下！？」「ㄟ，這邊好像也要先弄一下耶！」…結果又亂七八糟寫了一堆，搞的有點四不像的。</p><p>所以朋友們，如果看了程式之後，有那裡有更好的寫法的話。拜拖，請讓我知道，謝謝！！</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*OfUflXXYiaUUsWe4lc9V2A.gif" /></figure><p><a href="https://github.com/Daniel579/BlackJack">Daniel579/BlackJack</a></p><p>以上，謝謝大家！</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94375240fa70" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/%E4%BA%8C%E5%8D%81%E4%B8%80%E9%BB%9E%E4%BA%9E%E6%B4%B2%E6%85%88%E5%96%84%E6%92%B2%E5%85%8B%E7%8E%8B%E5%A4%A7%E8%B3%BD-94375240fa70">二十一點亞洲慈善撲克王大賽</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[製作 Stanford iOS 課程裡提到的翻牌記憶遊戲，Concentration App]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/%E8%A3%BD%E4%BD%9C-stanford-ios-%E8%AA%B2%E7%A8%8B%E8%A3%A1%E6%8F%90%E5%88%B0%E7%9A%84%E7%BF%BB%E7%89%8C%E8%A8%98%E6%86%B6%E9%81%8A%E6%88%B2-concentration-app-db34594b60e1?source=rss-e73650a33d28------2</link>
            <guid isPermaLink="false">https://medium.com/p/db34594b60e1</guid>
            <dc:creator><![CDATA[Siao Sian Huang]]></dc:creator>
            <pubDate>Fri, 10 Aug 2018 03:31:34 GMT</pubDate>
            <atom:updated>2018-08-10T03:35:19.338Z</atom:updated>
            <content:encoded><![CDATA[<p>話說，這個翻牌記憶遊戲卡了我好幾天。一直在嘗試用不一樣的方法看能不能解決，中間也推倒重做了數次。但也真真確確的加深了我對button的印象阿……(還好有Peter，不然卡的地方整個不知道要怎麼解決~~這次額外學到了DispatchQueue的用法！！)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*jscYIgwqwFPy8n_HGcGPPA.gif" /></figure><p><a href="https://github.com/Daniel579/MemoryCards">GitHub連結</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db34594b60e1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/%E8%A3%BD%E4%BD%9C-stanford-ios-%E8%AA%B2%E7%A8%8B%E8%A3%A1%E6%8F%90%E5%88%B0%E7%9A%84%E7%BF%BB%E7%89%8C%E8%A8%98%E6%86%B6%E9%81%8A%E6%88%B2-concentration-app-db34594b60e1">製作 Stanford iOS 課程裡提到的翻牌記憶遊戲，Concentration App</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[調色大師 — 天團]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/%E8%AA%BF%E8%89%B2%E5%A4%A7%E5%B8%AB-%E5%A4%A9%E5%9C%98-d3f9b509d537?source=rss-e73650a33d28------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3f9b509d537</guid>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Siao Sian Huang]]></dc:creator>
            <pubDate>Sat, 04 Aug 2018 18:27:07 GMT</pubDate>
            <atom:updated>2018-08-04T18:27:07.811Z</atom:updated>
            <content:encoded><![CDATA[<p>為了熟練outlet、action、UISlider、UIColor和UISwitch等功能</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*4Y-WQxc1UJe9xL62tUJztQ.gif" /></figure><p>調色和漸層分成兩個view去分別實現功能，所以當在調色的時候漸層的圖層會被隱藏起來。反之，在調漸層的時候，調色的圖層一樣會被隱藏起來</p><p>程式碼：</p><pre><strong>class</strong> ViewController: UIViewController {</pre><pre><strong>let</strong> gradientLayer = CAGradientLayer()</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> redSwitch: UISwitch!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> greenSwitch: UISwitch!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> blueSwitch: UISwitch!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> alphaSwitch: UISwitch!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> gradationSwitch: UISwitch!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> colorImageView: UIImageView!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> redValueLabel: UILabel!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> greenValueLabel: UILabel!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> blueValueLabel: UILabel!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> alphaValueLabel: UILabel!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> gradation: UILabel!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> redSlider: UISlider!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> greenSlider: UISlider!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> blueSlider: UISlider!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> alphaSlider: UISlider!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> gradationSlider: UISlider!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> GradationView: UIView!</pre><pre><em>/*</em></pre><pre><em>colorImageView:是顏色圖層的變數</em></pre><pre><em>readValueLabel:是顯示紅色的數值</em></pre><pre><em>greenValueLabel:是顯示綠色的數值</em></pre><pre><em>blueValueLabel:是顯示藍色的數值</em></pre><pre><em>alphaValueLabel:是顯示alpha的數值</em></pre><pre><em>gradation:是顯示漸層的數值</em></pre><pre><em>redSlider:是代表紅色Slider</em></pre><pre><em>greenSlider:是代表綠色Slider</em></pre><pre><em>blueSlider:是代表藍色Slider</em></pre><pre><em>alphaSlider:是代表alpha的Slider</em></pre><pre><em>gradationSlider:是代表漸層的Slider</em></pre><pre><em>GradationView:漸層的圖層</em></pre><pre><em>gradientLayer 漸層的一些設定會先寫在這裡面</em></pre><pre><em>*/</em></pre><pre><strong>@IBAction</strong> <strong>func</strong> RedSwitchChange(<strong>_</strong> sender: UISwitch) {</pre><pre><strong>if</strong> redSwitch.isOn {</pre><pre>redSlider.isEnabled = <strong>true</strong></pre><pre>}<strong>else</strong>{</pre><pre>redSlider.isEnabled = <strong>false</strong></pre><pre>}</pre><pre>}</pre><pre><strong>@IBAction</strong> <strong>func</strong> GreenSwitchChange(<strong>_</strong> sender: UISwitch) {</pre><pre><strong>if</strong> greenSwitch.isOn {</pre><pre>greenSlider.isEnabled = <strong>true</strong></pre><pre>}<strong>else</strong>{</pre><pre>greenSlider.isEnabled = <strong>false</strong></pre><pre>}</pre><pre>}</pre><pre><strong>@IBAction</strong> <strong>func</strong> BlueSwitchChange(<strong>_</strong> sender: UISwitch) {</pre><pre><strong>if</strong> blueSwitch.isOn {</pre><pre>blueSlider.isEnabled = <strong>true</strong></pre><pre>}<strong>else</strong>{</pre><pre>blueSlider.isEnabled = <strong>false</strong></pre><pre>}</pre><pre>}</pre><pre><strong>@IBAction</strong> <strong>func</strong> AlphaSwitchChange(<strong>_</strong> sender: UISwitch) {</pre><pre><strong>if</strong> alphaSwitch.isOn {</pre><pre>alphaSlider.isEnabled = <strong>true</strong></pre><pre>}<strong>else</strong>{</pre><pre>alphaSlider.isEnabled = <strong>false</strong></pre><pre>}</pre><pre>}</pre><pre><strong>@IBAction</strong> <strong>func</strong> GradationSwitchChange(<strong>_</strong> sender: UISwitch) {</pre><pre><strong>if</strong> gradationSwitch.isOn {</pre><pre>gradationSlider.isEnabled = <strong>true</strong></pre><pre>}<strong>else</strong>{</pre><pre>gradationSlider.isEnabled = <strong>false</strong></pre><pre>}</pre><pre>}</pre><pre><em>//以上幾個IBAction是控制自已的Slider。如果switch是開啟的話，相對應的Slider才能夠調整</em></pre><pre><strong>@IBAction</strong> <strong>func</strong> ColorControll(<strong>_</strong> sender: UISlider) {</pre><pre>GradationView.isHidden = <strong>true</strong></pre><pre>redValueLabel.text = String(format: &quot;%.2f&quot;, (redSlider.value))</pre><pre>greenValueLabel.text = String(format: &quot;%.2f&quot;, (greenSlider.value))</pre><pre>blueValueLabel.text = String(format: &quot;%.2f&quot;, (blueSlider.value))</pre><pre>alphaValueLabel.text = String(format: &quot;%.2f&quot;, (alphaSlider.value))</pre><pre>colorImageView.backgroundColor = UIColor(red: CGFloat(redSlider.value), green: CGFloat(greenSlider.value), blue: CGFloat(blueSlider.value), alpha: CGFloat(alphaSlider.value))</pre><pre>}</pre><pre><em>//當不管是拉動除了漸層之外的任一Slider，都會跳到這裡。</em></pre><pre><em>//一開始先隱藏漸層的圖層，接著各項設定的顯示都分別指向代表著自已的Slider</em></pre><pre><strong>@IBAction</strong> <strong>func</strong> gradationChange(<strong>_</strong> sender: UISlider) {</pre><pre>gradation.text = String(format: &quot;%.2f&quot;, (gradationSlider.value))</pre><pre>GradationView.isHidden = <strong>false</strong></pre><pre>gradientLayer.locations = [0.0, (NSNumber(floatLiteral: Double(sender.value)))]</pre><pre>}</pre><pre><em>//當拉動漸層的Slider時，會跳到這裡執行。</em></pre><pre><em>//設定漸層Slider的顯示，顯示漸層圖層，設定漸層的變化。</em></pre><pre><strong>override</strong> <strong>func</strong> viewDidLoad() {</pre><pre><strong>super</strong>.viewDidLoad()</pre><pre>redSlider.isEnabled = <strong>false</strong></pre><pre>greenSlider.isEnabled = <strong>false</strong></pre><pre>blueSlider.isEnabled = <strong>false</strong></pre><pre>alphaSlider.isEnabled = <strong>false</strong></pre><pre>gradationSlider.isEnabled = <strong>false</strong></pre><pre><em>//把slider的預設狀態設成無法調整</em></pre><pre>gradientLayer.frame = <strong>self</strong>.GradationView.bounds</pre><pre>gradientLayer.colors = [UIColor.orange.cgColor, UIColor.blue.cgColor, UIColor.red.cgColor, UIColor.yellow.cgColor, UIColor.green.cgColor]</pre><pre><strong>self</strong>.GradationView.layer.addSublayer(gradientLayer)</pre><pre>GradationView.isHidden = <strong>true</strong></pre><pre><em>//漸層的相關設定以及在app一開始時就先把漸層這圖層就先隱藏起來</em></pre><pre>}</pre><pre>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3f9b509d537" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/%E8%AA%BF%E8%89%B2%E5%A4%A7%E5%B8%AB-%E5%A4%A9%E5%9C%98-d3f9b509d537">調色大師 — 天團</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[猜數字之1A2b]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/%E7%8C%9C%E6%95%B8%E5%AD%97%E4%B9%8B1a2b-601bb4b2a20?source=rss-e73650a33d28------2</link>
            <guid isPermaLink="false">https://medium.com/p/601bb4b2a20</guid>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Siao Sian Huang]]></dc:creator>
            <pubDate>Wed, 01 Aug 2018 09:03:35 GMT</pubDate>
            <atom:updated>2018-08-01T09:12:34.355Z</atom:updated>
            <content:encoded><![CDATA[<p>為了練習使用shuffled和熟練之前已經學過的元件而挑戰這個app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*qbMYnL8JFM1SLHtWiFOdEw.gif" /></figure><p>要特別感謝之前的學姐有分享，不然我連怎麼下手都不知道….</p><p>程式碼：</p><pre><strong>import</strong> UIKit</pre><pre><strong>class</strong> ViewController: UIViewController {</pre><pre><strong>var</strong> topicNumber :String = &quot;&quot;</pre><pre><strong>var</strong> randomValue = 0...9</pre><pre><strong>var</strong> selectField : Int = 1</pre><pre><strong>var</strong> answerA : Int = 0</pre><pre><strong>var</strong> answerB : Int = 0</pre><pre><strong>var</strong> guessAnswer = [String](repeating:&quot;&quot;, count: 4)</pre><pre><strong>var</strong> topicArray = [String](repeating:&quot;&quot;, count: 4)</pre><pre><em>/*</em></pre><pre><em>topicNumber:答案變數</em></pre><pre><em>randomValue:答案範圍</em></pre><pre><em>selectField:猜測textfield的index</em></pre><pre><em>answerA:A的數量變數</em></pre><pre><em>answerB:B的數量變數</em></pre><pre><em>guessAnswer[]:猜測順序array</em></pre><pre><em>topicArray[]:答案順序array</em></pre><pre><em>*/</em></pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> guessTextField: UITextField!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> guessTextField2: UITextField!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> guessTextField3: UITextField!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> guessTextField4: UITextField!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> numberButton0: UIButton!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> numberButton1: UIButton!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> numberButton2: UIButton!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> numberButton3: UIButton!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> numberButton4: UIButton!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> numberButton5: UIButton!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> numberButton6: UIButton!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> numberButton7: UIButton!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> numberButton8: UIButton!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> numberButton9: UIButton!</pre><pre><strong>@IBAction</strong> <strong>func</strong> SelectTextField(<strong>_</strong> sender: UITextField) {</pre><pre><strong>self</strong>.view.endEditing(<strong>true</strong>)</pre><pre>selectField = sender.tag</pre><pre>}</pre><pre><em>//選擇那個猜測textfield和將鍵盤隱藏起來</em></pre><pre><strong>@IBAction</strong> <strong>func</strong> NumberInputs(<strong>_</strong> sender: UIButton) {</pre><pre><strong>if</strong> guessTextField.text == &quot;&quot; || guessTextField2.text == &quot;&quot; || guessTextField3.text == &quot;&quot; || guessTextField4.text == &quot;&quot; {</pre><pre>sender.isUserInteractionEnabled = <strong>false</strong></pre><pre>sender.alpha = 0.5</pre><pre>SwitchField(selectNumber: selectField, number: sender.tag )</pre><pre>}</pre><pre>}</pre><pre><em>//選定數字後將所選的數量半透明化同時將數字傳出來</em></pre><pre><strong>func</strong> SwitchField(selectNumber: Int, number: Int){</pre><pre><strong>switch</strong> selectNumber{</pre><pre><strong>case</strong> 1:</pre><pre>guessTextField.text = &quot;\(String(number))&quot;</pre><pre><strong>if</strong> guessTextField.text != &quot;&quot;{</pre><pre>guessTextField2.becomeFirstResponder()</pre><pre>SelectTextField(guessTextField2)</pre><pre>}</pre><pre>ReadyOK()</pre><pre><strong>case</strong> 2:</pre><pre>guessTextField2.text = &quot;\(String(number))&quot;</pre><pre><strong>if</strong> guessTextField2.text != &quot;&quot;{</pre><pre>guessTextField3.becomeFirstResponder()</pre><pre>SelectTextField(guessTextField3)</pre><pre>}</pre><pre>ReadyOK()</pre><pre><strong>case</strong> 3:</pre><pre>guessTextField3.text = &quot;\(String(number))&quot;</pre><pre><strong>if</strong> guessTextField3.text != &quot;&quot;{</pre><pre>guessTextField4.becomeFirstResponder()</pre><pre>SelectTextField(guessTextField4)</pre><pre>}</pre><pre>ReadyOK()</pre><pre><strong>case</strong> 4:</pre><pre>guessTextField4.text = &quot;\(String(number))&quot;</pre><pre><strong>if</strong> guessTextField4.text != &quot;&quot;{</pre><pre><strong>if</strong> guessTextField.text == &quot;&quot;{</pre><pre>guessTextField.becomeFirstResponder()</pre><pre>SelectTextField(guessTextField)</pre><pre>}</pre><pre><strong>if</strong> guessTextField2.text == &quot;&quot;{</pre><pre>guessTextField2.becomeFirstResponder()</pre><pre>SelectTextField(guessTextField2)</pre><pre>}</pre><pre><strong>if</strong> guessTextField3.text == &quot;&quot;{</pre><pre>guessTextField3.becomeFirstResponder()</pre><pre>SelectTextField(guessTextField3)</pre><pre>}</pre><pre>ReadyOK()</pre><pre>}</pre><pre><strong>default</strong>:</pre><pre><strong>break</strong></pre><pre>}</pre><pre>}</pre><pre><em>//輸入完數字後自動跳下一格，同時將ok隱藏起來</em></pre><pre><strong>@IBAction</strong> <strong>func</strong> SelectCancel(<strong>_</strong> sender: UIButton) {</pre><pre>guessTextField.text = &quot;&quot;</pre><pre>guessTextField2.text = &quot;&quot;</pre><pre>guessTextField3.text = &quot;&quot;</pre><pre>guessTextField4.text = &quot;&quot;</pre><pre>guessTextField.becomeFirstResponder()</pre><pre>selectField = 1</pre><pre>NumberButtonStateInit()</pre><pre>ReadyOK()</pre><pre>}</pre><pre><em>//將已選的數字鎖定清除</em></pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> resultTextView: UITextView!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> OKButton: UIButton!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> OKLabel: UILabel!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> happyGirlImage: UIImageView!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> winImage: UIImageView!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> NewGameImage: UIButton!</pre><pre><strong>@IBAction</strong> <strong>func</strong> NewGameButton(<strong>_</strong> sender: UIButton) {</pre><pre>happyGirlImage.isHidden = <strong>true</strong></pre><pre>winImage.isHidden = <strong>true</strong></pre><pre>NewGameImage.isHidden = <strong>true</strong></pre><pre>resultTextView.text = &quot;&quot;</pre><pre>guessTextField.text = &quot;&quot;</pre><pre>guessTextField2.text = &quot;&quot;</pre><pre>guessTextField3.text = &quot;&quot;</pre><pre>guessTextField4.text = &quot;&quot;</pre><pre>answerA = 0</pre><pre>answerB = 0</pre><pre>guessTextField.becomeFirstResponder()</pre><pre>selectField = 1</pre><pre>NumberButtonStateInit()</pre><pre>ReadyOK()</pre><pre>topicNumber = topic()</pre><pre>}</pre><pre><em>//再來一局</em></pre><pre><strong>@IBAction</strong> <strong>func</strong> OK(<strong>_</strong> sender: UIButton) {</pre><pre>guessAnswer[0] = (guessTextField.text)!</pre><pre>guessAnswer[1] = (guessTextField2.text)!</pre><pre>guessAnswer[2] = (guessTextField3.text)!</pre><pre>guessAnswer[3] = (guessTextField4.text)!</pre><pre><strong>for</strong> i <strong>in</strong> 0...3{</pre><pre><strong>if</strong> topicArray[i] == guessAnswer[i]{</pre><pre>answerB = answerB + 1</pre><pre>}</pre><pre>}</pre><pre><em>//B的數量</em></pre><pre><strong>for</strong> j <strong>in</strong> 0...3{</pre><pre><strong>for</strong> k <strong>in</strong> 0...3{</pre><pre><strong>if</strong> topicArray[j] == guessAnswer[k]{</pre><pre>answerA = answerA + 1</pre><pre>}</pre><pre>}</pre><pre>}</pre><pre><em>//A的數量</em></pre><pre>resultTextView.text = &quot;\(String(resultTextView.text))&quot; + &quot;\(guessAnswer[0])&quot; + &quot;\(guessAnswer[1])&quot; + &quot;\(guessAnswer[2])&quot; + &quot;\(guessAnswer[3])&quot; + &quot; : &quot; + &quot;\(String(answerA))&quot; + &quot;A&quot; + &quot;\(String(answerB))&quot; + &quot;B&quot; + &quot;\n&quot;</pre><pre><strong>if</strong> answerB != 4{</pre><pre>answerA = 0</pre><pre>answerB = 0</pre><pre>guessTextField.text = &quot;&quot;</pre><pre>guessTextField2.text = &quot;&quot;</pre><pre>guessTextField3.text = &quot;&quot;</pre><pre>guessTextField4.text = &quot;&quot;</pre><pre>NumberButtonStateInit()</pre><pre>guessTextField.becomeFirstResponder()</pre><pre>selectField = 1</pre><pre>}<strong>else</strong>{</pre><pre>happyGirlImage.isHidden = <strong>false</strong></pre><pre>winImage.isHidden = <strong>false</strong></pre><pre>NewGameImage.isHidden = <strong>false</strong></pre><pre>}</pre><pre>}</pre><pre><em>//將猜測的array和答案array比對</em></pre><pre><strong>func</strong> ReadyOK() -&gt; Void{</pre><pre><strong>if</strong> guessTextField.text != &quot;&quot;, guessTextField2.text != &quot;&quot;,</pre><pre>guessTextField3.text != &quot;&quot;,</pre><pre>guessTextField4.text != &quot;&quot;{</pre><pre>OKButton.isHidden = <strong>false</strong></pre><pre>OKLabel.isHidden = <strong>false</strong></pre><pre>}<strong>else</strong>{</pre><pre>OKButton.isHidden = <strong>true</strong></pre><pre>OKLabel.isHidden = <strong>true</strong></pre><pre>}</pre><pre>}</pre><pre><em>//判斷ok按鈕是否隱藏</em></pre><pre><strong>func</strong> NumberButtonStateInit() -&gt; Void{</pre><pre>numberButton0.isUserInteractionEnabled = <strong>true</strong></pre><pre>numberButton0.alpha = 1</pre><pre>numberButton1.isUserInteractionEnabled = <strong>true</strong></pre><pre>numberButton1.alpha = 1</pre><pre>numberButton2.isUserInteractionEnabled = <strong>true</strong></pre><pre>numberButton2.alpha = 1</pre><pre>numberButton3.isUserInteractionEnabled = <strong>true</strong></pre><pre>numberButton3.alpha = 1</pre><pre>numberButton4.isUserInteractionEnabled = <strong>true</strong></pre><pre>numberButton4.alpha = 1</pre><pre>numberButton5.isUserInteractionEnabled = <strong>true</strong></pre><pre>numberButton5.alpha = 1</pre><pre>numberButton6.isUserInteractionEnabled = <strong>true</strong></pre><pre>numberButton6.alpha = 1</pre><pre>numberButton7.isUserInteractionEnabled = <strong>true</strong></pre><pre>numberButton7.alpha = 1</pre><pre>numberButton8.isUserInteractionEnabled = <strong>true</strong></pre><pre>numberButton8.alpha = 1</pre><pre>numberButton9.isUserInteractionEnabled = <strong>true</strong></pre><pre>numberButton9.alpha = 1</pre><pre>}</pre><pre><em>//將全部數字狀態回復</em></pre><pre><strong>func</strong> topic() -&gt; String{</pre><pre><strong>let</strong> randomNumber = randomValue.shuffled()</pre><pre><strong>for</strong> i <strong>in</strong> 0...3{</pre><pre>topicArray[i] = &quot;\(Int(randomNumber[i]))&quot;</pre><pre>topicNumber = topicNumber + &quot;\(topicArray[i])&quot;</pre><pre>}</pre><pre>print(topicNumber)</pre><pre><strong>return</strong> topicNumber</pre><pre>}</pre><pre><em>//亂數抓取答案</em></pre><pre><strong>override</strong> <strong>func</strong> viewDidLoad() {</pre><pre><strong>super</strong>.viewDidLoad()</pre><pre>happyGirlImage.isHidden = <strong>true</strong></pre><pre>winImage.isHidden = <strong>true</strong></pre><pre>NewGameImage.isHidden = <strong>true</strong></pre><pre>ReadyOK()</pre><pre>topicNumber = topic()</pre><pre>}</pre><pre><em>//一載入畫面時的初始化</em></pre><pre>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=601bb4b2a20" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/%E7%8C%9C%E6%95%B8%E5%AD%97%E4%B9%8B1a2b-601bb4b2a20">猜數字之1A2b</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[AI之cocoapods 安裝與使用]]></title>
            <link>https://medium.com/@siaosianhuang/ai%E4%B9%8Bcocoapods-%E5%AE%89%E8%A3%9D%E8%88%87%E4%BD%BF%E7%94%A8-8c0606434aa8?source=rss-e73650a33d28------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c0606434aa8</guid>
            <dc:creator><![CDATA[Siao Sian Huang]]></dc:creator>
            <pubDate>Mon, 30 Jul 2018 04:40:57 GMT</pubDate>
            <atom:updated>2018-07-30T04:40:57.083Z</atom:updated>
            <content:encoded><![CDATA[<p>要運用Dialogflow到app中的話，需要加入API。那要加入的api就可以使用cocoapods來下載安裝和管理了。</p><p>第一步，當然就是要先有cocoapods嘍。但要安裝cocoapods的話要先檢查一下Ruby的版本。版本太低的話可能會安裝不了。所以先在Launchpad中找到&quot;其它&quot;這個資料夾，在這資料中裡有個叫&quot;終端機&quot;的東西。先將終端機打開來，以便執行指令。</p><p>接下來就是查詢Ruby的版本嘍</p><pre>ruby -v</pre><p>要升級ruby之前，要先安裝rvm</p><pre>curl -L get.rvm.io | bash -s stable<br>source ~/.bashrc<br>source ~/.bash_profile</pre><p>查看rvm的版本</p><pre>rvm -v</pre><p>列出ruby可安裝的版本</p><pre>rvm list known</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*zOHBGdmQkUC58qUVxVTqeQ.png" /></figure><p>選一個版本安裝</p><pre>rvm install 2.5.1</pre><p>執行期間會需要按兩次enter鍵，第二次按下後需要輸入這個mac的密碼</p><p>把ruby的版本設為預設版本</p><pre>rvm use 2.5.1 --default</pre><p>到這之後，網路上可能有些文章會出現需要做&quot;更換源&quot;這個動作。這是因為使用這個需要連線到外部的網站，但那網站在大陸會被擋，所以才需要做變更。所以這裡我們這就不再做變動了喲！</p><p>接下來開始安裝cocoapods，一樣在終端機上輸入下面指令</p><pre>sudo gem install -n /usr/local/bin cocoapods</pre><p>然後安裝cocoapods的資料庫</p><pre>pod setup</pre><p>接著就是等它安裝完嘍</p><h3><strong>cocoapods的使用方式</strong></h3><p>首先先新建一個Xcode的專案(例如TalkAI)</p><p>假設此專案是存在桌面上的A02這個資料夾中，所以他的路徑是desktop/A02/TalkAI 這樣</p><p>先在終端機中找到TalkAI這個目錄裡</p><p>可以透過下面的指令一層一層的找到</p><pre>cd desktop<br>cd A02<br>cd TalkAI</pre><p>或者</p><pre>cd ~/desktop/A02/TalkAI/</pre><p>確認是不是有找到了</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*onyY0uzAjA84vCGiQz8aSA.png" /></figure><p>找到後執行</p><pre>pod init</pre><p>之後會發現在TalkAI的資料中多了一個podfile的檔案，執行這個檔案後會看到下圖</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c-rRhKRkRahGsQTekRGMsQ.png" /></figure><p>之後可以透過這裡下載所需要的api，例如下圖</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EIj_RBhV_2L6AOhui-6_2g.png" /></figure><p>將所需要api填入後就可以下指令安裝了</p><pre>pod install</pre><p>最後，安裝完後回到TalkAI的資料夾中，會發現有個叫TalkAI.xcworkspace的檔案出現。最後要執行的話要執行這個檔案喔！</p><p>以上，是我自已安裝執行的經驗，給有需要的人。如果有那邊說錯或沒說到的地方，還請麻煩告訴我一下喔。謝謝~~</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c0606434aa8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[每日一問之Dialogflow \ cocoapods好難搞]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/%E6%AF%8F%E6%97%A5%E4%B8%80%E5%95%8F%E4%B9%8Bdialogflow-cocoapods%E5%A5%BD%E9%9B%A3%E6%90%9E-a37996f4f720?source=rss-e73650a33d28------2</link>
            <guid isPermaLink="false">https://medium.com/p/a37996f4f720</guid>
            <dc:creator><![CDATA[Siao Sian Huang]]></dc:creator>
            <pubDate>Mon, 30 Jul 2018 03:43:49 GMT</pubDate>
            <atom:updated>2018-07-30T03:43:49.408Z</atom:updated>
            <content:encoded><![CDATA[<p>其實之前就有看到過cocoapods這個單字了，但一直不知道那是什麼、幹嘛用的。為了這個搞出這個app，對cocoapods有了初步的了解。(真的心臟很大，也不怕搞壞XD)</p><p>原來cocoapods是用來管理第三方資料庫的。就是當要引用第三方的api時可以用cocoapods來管理、下載安裝。關於怎麼使用和安裝，之後有空再整理一份資料出來，目前網路上都找的到。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*oAPyfybyaXSC71NDxsqn5w.gif" /></figure><p>程式碼：</p><pre><strong>import</strong> UIKit</pre><pre><strong>import</strong> ApiAI</pre><pre><strong>class</strong> ViewController: UIViewController {</pre><pre><em>/*</em></pre><pre><em>因為要使用AI,所以先import ApiAI</em></pre><pre><em>把提問的textfield設成questionsMessage</em></pre><pre><em>把ai回復的textview設成answersTextView</em></pre><pre><em>當問題問完，需要個button把問題丟出去，所以把button設成sendMessage</em></pre><pre><em>*/</em></pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> questionsMessage: UITextField!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> answersTextView: UITextView!</pre><pre><strong>@IBAction</strong> <strong>func</strong> sendMessage(<strong>_</strong> sender: UIButton) {</pre><pre><strong>let</strong> request = ApiAI.shared().textRequest()</pre><pre><strong>if</strong> <strong>let</strong> text = questionsMessage.text, text != &quot;&quot; {</pre><pre>request?.query = text</pre><pre>} <strong>else</strong> {</pre><pre><strong>return</strong></pre><pre>}</pre><pre><em>//上面這段是先確認問題輸入框內是有字元，然後才把問題的內容丟給api.AI裡的function去處理</em></pre><pre>request?.setMappedCompletionBlockSuccess({ (request, response) <strong>in</strong></pre><pre><strong>let</strong> response = response <strong>as</strong>! AIResponse</pre><pre><strong>if</strong> <strong>let</strong> textResponse = response.result.fulfillment.speech {</pre><pre><strong>self</strong>.answersTextView.text = textResponse</pre><pre>}</pre><pre>}, failure: { (request, error) <strong>in</strong></pre><pre>print(error!)</pre><pre>})</pre><pre><em>//上面這段是把api.AI回傳回來的內容顯示在textview裡</em></pre><pre>ApiAI.shared().enqueue(request)</pre><pre>questionsMessage.text = &quot;&quot;</pre><pre><em>//上面這段是把問題丟出後，會將提問的字清除，以方便輸入下個問題</em></pre><pre>}</pre><pre><strong>override</strong> <strong>func</strong> viewDidLoad() {</pre><pre><strong>super</strong>.viewDidLoad()</pre><pre><em>// Do any additional setup after loading the view, typically from a nib.</em></pre><pre>}</pre><pre><strong>override</strong> <strong>func</strong> touchesBegan(<strong>_</strong> touches: Set&lt;UITouch&gt;, with event: UIEvent?) {</pre><pre><strong>self</strong>.view.endEditing(<strong>true</strong>)</pre><pre>}</pre><pre><em>//上面這個function是ai回覆的textview會被鍵盤擋住</em></pre><pre><em>//所以這個功能是當輸入完問題後，可以點擊一下畫面上其它地方，然後會把鍵盤收起來。</em></pre><pre><em>//在實作這個功能之前，要先在提問的textfield上點右鍵，與delegate做連結。</em></pre><pre>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a37996f4f720" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/%E6%AF%8F%E6%97%A5%E4%B8%80%E5%95%8F%E4%B9%8Bdialogflow-cocoapods%E5%A5%BD%E9%9B%A3%E6%90%9E-a37996f4f720">每日一問之Dialogflow \ cocoapods好難搞</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[相約與神同行計時 — Date Picker 和 Date 的練習]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/%E7%9B%B8%E7%B4%84%E8%88%87%E7%A5%9E%E5%90%8C%E8%A1%8C%E8%A8%88%E6%99%82-date-picker-%E5%92%8C-date-%E7%9A%84%E7%B7%B4%E7%BF%92-6c541ee67454?source=rss-e73650a33d28------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c541ee67454</guid>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Siao Sian Huang]]></dc:creator>
            <pubDate>Sat, 28 Jul 2018 13:52:22 GMT</pubDate>
            <atom:updated>2018-07-28T13:52:22.817Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*vNyg47gkvB9Tk2HHb1cpQA.gif" /></figure><p>時間計算應該不會太難才對，但dateComponents(_:from:to:)怎麼都搞不定。只能很笨的用算式套了，所以這個還要再研究一下！！</p><p>程式碼：</p><pre><strong>import</strong> UIKit</pre><pre><strong>class</strong> MainViewController: UIViewController {</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> meetDateTextField: UITextField!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> meetDatePicker: UIDatePicker!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> countDateTextField: UITextField!</pre><pre><strong>@IBAction</strong> <strong>func</strong> meetDateChoose(<strong>_</strong> sender: UIDatePicker) {</pre><pre><strong>let</strong> now = Date()</pre><pre><strong>let</strong> dateformate = DateFormatter()</pre><pre>dateformate.dateFormat = &quot;MM-dd-yyyy HH:mm&quot;</pre><pre>meetDateTextField.text = dateformate.string(from: meetDatePicker.date)</pre><pre><strong>let</strong> Interval = (sender.date).timeIntervalSince(now)</pre><pre><strong>var</strong> day: Double = 0</pre><pre><strong>var</strong> dayInt: Int = 0</pre><pre><strong>var</strong> hour: Double = 0</pre><pre><strong>var</strong> hourInt: Int = 0</pre><pre><strong>var</strong> minute: Int = 0</pre><pre>day = (Interval/60/60/24)</pre><pre>dayInt = Int(day)</pre><pre>hour = ((Interval/60/60)-Double(dayInt*24))</pre><pre>hourInt = Int(hour)</pre><pre>minute = ((Int)(Interval/60)%60)</pre><pre>countDateTextField.text = &quot;\(dayInt)天，&quot; + &quot;\(hourInt)H:&quot; + &quot;\(minute)m:&quot; + &quot;\(((Int)(Interval)%60))s&quot;</pre><pre>}</pre><pre><strong>override</strong> <strong>func</strong> viewDidLoad() {</pre><pre><strong>super</strong>.viewDidLoad()</pre><pre>}</pre><pre>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c541ee67454" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/%E7%9B%B8%E7%B4%84%E8%88%87%E7%A5%9E%E5%90%8C%E8%A1%8C%E8%A8%88%E6%99%82-date-picker-%E5%92%8C-date-%E7%9A%84%E7%B7%B4%E7%BF%92-6c541ee67454">相約與神同行計時 — Date Picker 和 Date 的練習</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>