<?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 Sgui on Medium]]></title>
        <description><![CDATA[Stories by Sgui on Medium]]></description>
        <link>https://medium.com/@aaron.qs2005?source=rss-565c9186eae3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*M9d-TW3nnBOoINEhe3SzoA@2x.jpeg</url>
            <title>Stories by Sgui on Medium</title>
            <link>https://medium.com/@aaron.qs2005?source=rss-565c9186eae3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 23:43:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aaron.qs2005/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[#1 ＿Q&A問答題 ｜ 猜猜大挑戰 App]]></title>
            <link>https://medium.com/peter-pan-swift-ios-class/1-q-a%E5%95%8F%E7%AD%94%E9%A1%8C-%E7%8C%9C%E7%8C%9C%E5%A4%A7%E6%8C%91%E6%88%B0-app-1dbea7144d34?source=rss-565c9186eae3------2</link>
            <guid isPermaLink="false">https://medium.com/p/1dbea7144d34</guid>
            <dc:creator><![CDATA[Sgui]]></dc:creator>
            <pubDate>Thu, 27 Oct 2022 07:31:28 GMT</pubDate>
            <atom:updated>2022-10-27T11:02:59.746Z</atom:updated>
            <content:encoded><![CDATA[<p>原本要製作雙人版 紅白猜題大賽…難產先來一個單人版 ＸＤ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*lahevveusnICb1L9M-AUkg.gif" /></figure><h3>｜ 功能簡介</h3><ul><li>Slider (顯示題數進度條)</li><li>Label (顯示題目、分數、提示)</li><li>Button (選項、下一題、在玩一次)</li><li>點選Button 變色 按下一題 恢復原狀</li><li>答對一題加 10 分</li><li>畫面上顯示目前題目是第幾題</li><li>題目順序跟選項順序每次出現時都要不一樣</li><li>訊息視窗應用(詢問是否再玩一次)</li></ul><h3>｜ <strong><em>Swift 程式碼</em></strong></h3><p>Code of QuestionViewController.swift</p><pre>//  ViewController.swift</pre><pre>// </pre><pre>//  Created by aaron on 2022/10/18.</pre><pre>//</pre><pre><strong>import</strong> UIKit</pre><pre><strong>class</strong> ViewController: UIViewController {</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> questionNumberLabel: UILabel!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> scoreLabel: UILabel!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> questionLabel: UILabel!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> hintLabel: UILabel!</pre><pre><strong>@IBOutlet</strong> <strong>weak</strong> <strong>var</strong> questionSlider: UISlider!</pre><pre><strong>@IBOutlet</strong> <strong>var</strong> answerButton: [UIButton]!</pre><pre><strong>var</strong> questions = [Question]()</pre><pre><strong>var</strong> index = 0</pre><pre><strong>var</strong> score = 0</pre><pre><strong>var</strong> count = 1</pre><pre><strong>var</strong> rightAnswer = &quot;&quot;</pre><pre><strong>override</strong> <strong>func</strong> viewDidLoad() {</pre><pre><strong>super</strong>.viewDidLoad()</pre><pre><strong>let</strong> question1 = Question(description: &quot;白雪公主跟包公結婚，生下的女兒叫什麼名字？&quot;, answer: &quot;灰姑娘&quot;, option: [&quot;包姑娘&quot;,&quot;白姑娘&quot;,&quot;黑姑娘&quot;,&quot;灰姑娘&quot;])</pre><pre>questions.append(question1)</pre><pre><strong>let</strong> question2 = Question(description: &quot;地球.太陽.星星.月亮哪一個是啞巴? （提示：魯冰花）&quot;, answer: &quot;星星&quot;, option: [&quot;月亮&quot;,&quot;太陽&quot;,&quot;星星&quot;,&quot;地球&quot;])</pre><pre>questions.append(question2)</pre><pre><strong>let</strong> question3 = Question(description: &quot;把妹要開什麼車？&quot;, answer: &quot;垃圾車&quot;, option: [&quot;小貨車&quot;,&quot;進口車&quot;,&quot;國產車&quot;,&quot;垃圾車&quot;])</pre><pre>questions.append(question3)</pre><pre><strong>let</strong> question4 = Question(description: &quot;麵包超人扭到腳會變成什麼?&quot;, answer: &quot;牛角麵包&quot;, option: [&quot;肉鬆麵包&quot;,&quot;花生麵包&quot;,&quot;牛角麵包&quot;,&quot;菠蘿麵包&quot;])</pre><pre>questions.append(question4)</pre><pre><strong>let</strong> question5 = Question(description: &quot;哪種動物最熱情？（提示：熱情的沙漠）&quot;, answer: &quot;黑豬&quot;, option: [&quot;黑狗&quot;,&quot;黑豬&quot;,&quot;黑熊&quot;,&quot;黑貓&quot;])</pre><pre>questions.append(question5)</pre><pre><strong>let</strong> question6 = Question(description: &quot;企鵝的台語是什麼？&quot;, answer: &quot;徛鵝&quot;, option: [&quot;去鵝&quot;,&quot;企鵝&quot;,&quot;不倒鵝&quot;,&quot;徛鵝&quot;])</pre><pre>questions.append(question6)</pre><pre><strong>let</strong> question7 = Question(description: &quot;一歲的蜜蜂到了，一百歲變成甚麼?&quot;, answer: &quot;高齡蜂&quot;, option: [&quot;長壽蜂&quot;,&quot;龜齡蜂&quot;,&quot;高齡蜂&quot;,&quot;長命蜂&quot;])</pre><pre>questions.append(question7)</pre><pre><strong>let</strong> question8 = Question(description: &quot;魚在水裡玩會變成什麼？&quot;, answer: &quot;魚丸&quot;, option: [&quot;美人魚&quot;,&quot;小丑魚&quot;,&quot;鹹魚&quot;,&quot;魚丸&quot;])</pre><pre>questions.append(question8)</pre><pre><strong>let</strong> question9 = Question(description: &quot;怎麼讓珍珠奶茶變大杯的？&quot;, answer: &quot;唸大悲咒&quot;, option: [&quot;喝別人的&quot;,&quot;唸大悲咒&quot;,&quot;倒立喝茶&quot;,&quot;加水稀釋&quot;])</pre><pre>questions.append(question9)</pre><pre><strong>let</strong> question10 = Question(description: &quot;國人不洗澡會變成什麼人？&quot;, answer: &quot;泰國人&quot;, option: [&quot;台灣人&quot;,&quot;日本人&quot;,&quot;印度人&quot;,&quot;泰國人&quot;])</pre><pre>questions.append(question10)</pre><pre><strong>let</strong> question11 = Question(description: &quot;為什麼你交不到女朋友？&quot;, answer: &quot;選擇不在我身上&quot;, option: [&quot;我無所謂&quot;,&quot;我沒錢&quot;,&quot;我太帥了&quot;,&quot;選擇不在我身上&quot;])</pre><pre>questions.append(question11)</pre><pre><strong>let</strong> question12 = Question(description: &quot;在麥當勞過生日點什麼？&quot;, answer: &quot;薯條加漢堡&quot;, option: [&quot;冰炫風&quot;,&quot;麥克雞塊&quot;,&quot;蘋果派&quot;,&quot;薯條加漢堡&quot;])</pre><pre>questions.append(question12)</pre><pre><strong>let</strong> question13 = Question(description: &quot;哪個科系畢業最適合賣壽司？&quot;, answer: &quot;美術系&quot;, option: [&quot;外文系&quot;,&quot;電機系&quot;,&quot;醫學系&quot;,&quot;美術系&quot;])</pre><pre>questions.append(question13)</pre><pre><strong>let</strong> question14 = Question(description: &quot; 小黑小白小紅小綠,四人搭飛機誰最會暈機？&quot;, answer: &quot;小白&quot;, option: [&quot;小黑&quot;,&quot;小紅&quot;,&quot;小綠&quot;,&quot;小白&quot;])</pre><pre>questions.append(question14)</pre><pre><strong>let</strong> question15 = Question(description: &quot; 甲乙丙丁,哪一個字最酷？&quot;, answer: &quot;丁&quot;, option: [&quot;甲&quot;,&quot;乙&quot;,&quot;丙&quot;,&quot;丁&quot;])</pre><pre>questions.append(question15)</pre><pre><strong>let</strong> question16 = Question(description: &quot; 哪種花最好養？&quot;, answer: &quot;菊花&quot;, option: [&quot;百合花&quot;,&quot;玫瑰花&quot;,&quot;菊花&quot;,&quot;蘭花&quot;])</pre><pre>questions.append(question16)</pre><pre>questions.shuffle()</pre><pre>startGame()</pre><pre>}</pre><pre><strong>func</strong> startGame(){</pre><pre>questions[index].option.shuffle()</pre><pre><strong>for</strong> i <strong>in</strong> 0...3{</pre><pre>answerButton[i].setTitle(questions[index].option[i], for: .normal)</pre><pre>}</pre><pre>rightAnswer = questions[index].answer</pre><pre>questionLabel.text = questions[index].description</pre><pre>questionSlider.value = Float(count)</pre><pre>}</pre><pre><strong>@IBAction</strong> <strong>func</strong> clickAnswer(_ sender: UIButton) {</pre><pre>sender.backgroundColor = .red</pre><pre>// sender.backgroundColor = .systemGray3</pre><pre><strong>if</strong> sender.currentTitle == rightAnswer {</pre><pre>score = score+10</pre><pre>scoreLabel.text = &quot;分數：\(score)&quot;</pre><pre>hintLabel.text = &quot;恭喜答對，加分加分！&quot;</pre><pre>}<strong>else</strong>{</pre><pre>hintLabel.text = &quot;答錯了，(T＿T). . .不用哭哭換下一題！&quot;</pre><pre>}</pre><pre>}</pre><pre><strong>@IBAction</strong> <strong>func</strong> nextQuestion(_ sender: <strong>Any</strong>) {</pre><pre>index = index+1</pre><pre>count = count+1</pre><pre>questionSlider.value = Float(count)</pre><pre>hintLabel.text = &quot;&quot;</pre><pre>questionNumberLabel.text = &quot;第\(count)題&quot;</pre><pre>answerButton.forEach { button <strong>in</strong></pre><pre>button.backgroundColor = .systemGray3</pre><pre>}</pre><pre><strong>if</strong> count == 11  {</pre><pre>index = 0</pre><pre>count = 1</pre><pre>questionNumberLabel.text = &quot;第\(count)題&quot;</pre><pre>score = 0</pre><pre>scoreLabel.text = &quot;分數：\(score)&quot;</pre><pre>questions.shuffle()</pre><pre>}</pre><pre>startGame()</pre><pre>}</pre><pre><strong>func</strong> reset(){</pre><pre>index = 0</pre><pre>count = 1</pre><pre>score = 0</pre><pre>questionNumberLabel.text = &quot;第\(count)題&quot;</pre><pre>scoreLabel.text = &quot;分數：\(score)&quot;</pre><pre>startGame()</pre><pre>}</pre><pre><strong>@IBAction</strong> <strong>func</strong> tryAgain(_ sender: <strong>Any</strong>) {</pre><pre><strong>let</strong> controller = UIAlertController(title: &quot;再玩一次？&quot;, message: &quot;資料關閉視窗後清除～～&quot;, preferredStyle: UIAlertController.Style.alert)</pre><pre><strong>let</strong> noAction = UIAlertAction(title: &quot;取消&quot;, style: UIAlertAction.Style.default, handler: <strong>nil</strong>)</pre><pre>controller.addAction(noAction)</pre><pre><strong>let</strong> yesAction = UIAlertAction(title: &quot;確定&quot;, style: UIAlertAction.Style.default){_ <strong>in</strong></pre><pre><strong>self</strong>.reset()</pre><pre>}</pre><pre>controller.addAction(yesAction)</pre><pre>present(controller,animated:<strong>true</strong>,completion:<strong>nil</strong>)</pre><pre>}</pre><pre>}</pre><h3>｜ 參考<strong><em>文章</em></strong></h3><ul><li><a href="https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84%E8%A9%A6%E7%85%89-%E5%8B%87%E8%80%85%E7%9A%84-100-%E9%81%93-swift-ios-app-%E8%AC%8E%E9%A1%8C/25-%E9%81%B8%E6%93%87%E9%A1%8C-app-234770143812">#25 選擇題 App</a></li><li><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/%E4%BD%9C%E6%A5%AD-%E9%81%B8%E6%93%87%E9%A1%8C-app-%E6%A3%92%E7%90%83%E8%8B%B1%E6%96%87%E6%B8%AC%E9%A9%97-2d7628d7ca45">[作業]選擇題 App — 棒球英文測驗</a></li><li><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/23-q-a-%E9%81%B8%E6%93%87%E9%A1%8C-66a33d619605">#23 Q&amp;A 選擇題</a></li><li><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%B7%B4%E7%BF%92%E7%AD%86%E8%A8%98-43-%E5%95%8F%E7%AD%94%E9%A1%8Capp-%E5%9F%8E%E5%B8%82%E5%9C%B0%E6%A8%99%E5%A4%A7%E6%8C%91%E6%88%B0-733eac886dfa">練習筆記 43 ：問答題App-城市地標大挑戰</a></li><li><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/3-q-a%E5%95%8F%E7%AD%94%E9%A1%8C-%E6%B0%B4%E6%9E%9C%E7%99%BC%E9%9F%B3%E7%B7%B4%E7%BF%92-33203cb4cf0c">#4 Q&amp;A問答題｜水果發音練習</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1dbea7144d34" width="1" height="1" alt=""><hr><p><a href="https://medium.com/peter-pan-swift-ios-class/1-q-a%E5%95%8F%E7%AD%94%E9%A1%8C-%E7%8C%9C%E7%8C%9C%E5%A4%A7%E6%8C%91%E6%88%B0-app-1dbea7144d34">#1 ＿Q&amp;A問答題 ｜ 猜猜大挑戰 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>
    </channel>
</rss>