close

Step1. create 一個xcode project, 這裏選擇single view即可.

Step2. 利用storyboard拉出你想要的介面

螢幕快照 2014-11-28 上午12.10.27  

Step3. 在ViewController.h檔中宣告你要用的變數與方法(function)

 

Method : user所選擇的運算子

0 : user按下equal

1 : multiply

2 : divide

3 : subtract

4 : add

selectNumber為user鍵入的數字

runningTotal是為了存運算元

螢幕快照 2014-11-28 上午12.10.50  

Step4. 將你宣告的變數和storyboard的button建立連結

點選整個使外框呈現藍色,選擇左邊的viewcontroller按鈕.

螢幕快照 2014-11-28 上午12.12.55

 

選擇欄位最右邊的箭頭

螢幕快照 2014-11-28 上午12.19.41  

使用拖曳的方式拖拉到storyboard上對應的button或label等

螢幕快照 2014-11-28 上午12.13.37 

 

Step4. 在ViewController.m檔中實作方法

基本上0~9的function都長一樣,只改變了第二行加的數字.

Screen.text 則是螢幕顯示的結果.

螢幕快照 2014-11-28 上午12.11.23  

使用switch依照傳入的method去改變RunningTotal的值.

螢幕快照 2014-11-28 上午12.11.59  

螢幕快照 2014-11-28 上午12.12.15  

 

 

arrow
arrow
    文章標籤
    objective-c ios xcode
    全站熱搜
    創作者介紹

    貪吃鬼少女宅 發表在 痞客邦 留言(0) 人氣()