
本範例目的是使用按鈕(button)去改變開關(UISwitch)之狀態, 並取得切換狀態的值,
程式執行後, 點選Switch印出switch的status
1. storyboard中加入switch, button
2.與viewcontroller.h檔建立程式關聯性, 程式碼如下
Will 發表在 痞客邦 留言(0) 人氣(2,669)

本範例目的是使用按鈕(button)去改變開關(UISwitch)之狀態
1. storyboard中加入switch, button
2.與viewcontroller.h檔建立程式關聯性, 程式碼如下
@property (strong, nonatomic) IBOutletUISwitch *mySwitch;
- (IBAction)toClick:(id)sender;
Will 發表在 痞客邦 留言(0) 人氣(587)

實作呼叫上浮選單UIActionSheet
1.實作一個按鈕,點擊按鈕實行如下
Will 發表在 痞客邦 留言(2) 人氣(1,611)

1.新增兩張圖片進入專案中, 本例中兩張圖片分別命名為playbutton.jpg, stopbutton.jpg
2.storyboard上加入一個button, 並在右邊image屬性欄位設定一張預設圖片為playbutton.jpg
3.拖曳button至viewcontroller.h檔建立程式關聯性, 並設定為outlet屬性
4.實作程式碼viewcontroller.m的viewdidloaf中
Will 發表在 痞客邦 留言(0) 人氣(1,713)

此範例目的是點擊按鈕顯示文字的應用,並計算及顯示按了幾下
1.stroryboard中新增一個button與label, 並與viewController.h檔建立程式關聯性(若不知道如何建立關聯性可參考範例一
button設定為action, label設定為outlet
2.在viewController.h檔中新增一個iVar,命名為count並紀錄次數
3.並在viewController.m檔中設定初始值為0
Will 發表在 痞客邦 留言(0) 人氣(649)

點擊button, labe區顯示文字
1.點選storyboard, 拖曳一個label與一個button到view controller上
2.按住alt點選viewController.h檔, 滑鼠右鍵點選label往右拉到viewController.h, 設定為outlet, 並且命名為labelArea
3.滑鼠右鍵點選button往右拉到viewController.h, 設定為action, 並且命名為toClick
Will 發表在 痞客邦 留言(0) 人氣(491)