此範例透過三個滾軸讓使用者選擇項目,
此範例為有3個component,每個component又各有三個選項,
使用者選擇後點擊按鈕顯示至lableView上。
viewController.h
Will 發表在 痞客邦 留言(0) 人氣(1,605)
UIPickerView透過一個滾軸讓使用者選擇項目,
此範例為有data1 to data3假資料,
使用者選擇後點擊按鈕顯示至lableView上。
viewController.h
Will 發表在 痞客邦 留言(0) 人氣(704)
此範例為用一個NavigationBar,並新增一個Undo與Done按鈕,
控制已編輯的UITextView。
ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController<UITextViewDelegate>
{
NSString *prevText;
}
@end
Will 發表在 痞客邦 留言(0) 人氣(223)
此範例為一個日期選擇的應用,
點擊button後,觸發datePciker並顯示於label上,
將UIDatePicker調整到使用者的生日,
計算年齡後並印在Label。
Will 發表在 痞客邦 留言(0) 人氣(131)
此範例為一個日期選擇的應用,
點擊button後,觸發datePciker並顯示於label上。
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIDatePicker *myDatePicker;
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
- (IBAction)toEnter:(id)sender;
- (IBAction)datePickerChanged:(id)sender;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)toEnter:(id)sender {
if( _myDatePicker.hidden == YES){ //若datePciker為隱藏則將它開啟
[_myDatePicker setHidden:NO];
}else{
[_myDatePicker setHidden:YES];
}
}
- (IBAction)datePickerChanged:(id)sender {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"YYYY/MM/dd"]; //設定date顯示格式
NSString *dateString = [dateFormatter stringFromDate:[_myDatePicker date]]; //轉為字串格式
_dateLabel.text = dateString;
}
@end
Will 發表在 痞客邦 留言(0) 人氣(11)
此範例為點擊stepper,計數顯示在label上
1.storyboard中加入stepper, label
2.設定stepper的行為autorepeat, continus
3.建立程式關聯性
Will 發表在 痞客邦 留言(0) 人氣(98)

此範例目的為滑動UISlider, 並顯示此音量控制元件的數值
1. stroryboard中加入slider, label
2. 加入程式關聯性
@property (weak, nonatomic) IBOutletUILabel *valueLabel;
property (weak, nonatomic) IBOutletUISlider *mySlider;
- (IBAction)sliderValueChange:(id)sender;
Will 發表在 痞客邦 留言(0) 人氣(444)

本範例目的是使用按鈕(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)