一、UIAlertView
1、初始化
UIAlertView *alertView =[[UIAlertView alloc] initWithTitle:@"rating" message:@"can you please rate our app" delegate:nil cancelButtonTitle:@"YES" otherButtonTitles:@"NO", nil];
1、title 显示最上面的文字
2、message title下面简序
3、delegate 委托
4、cancelButtonTitle 自定义按钮
2、监听方法
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
二、UISwitch
1、初始化
UISwitch.*uiSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(100, 160, 50, 10)];[
self.uiSwitch setOn:NO]; //设置默认值
[self.uiSwitch addTarget:self action:@selector(switchChange:) forControlEvents:UIControlEventValueChanged]; //设置监听方法
三、UIPickerView
1、初始化
[ [UIPickerView alloc]init];
self.myPicker.delegate = self;
2、为选择器添加多个组件
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
3、组件里添加多个选项
- (NSInteger) pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
4、根据组件标示显示文本数据
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
四、UIDatePicker
1、初始化
[ [UIDatePicker alloc]init];
2、设置类型
self.myDatePicker.datePickerMode = UIDatePickerModeDateAndTime;
3、监听方法
[self.myDatePicker addTarget:self action:@selector(datePickerDateChanged:) forControlEvents:UIControlEventValueChanged];
五、UISlider
1、初始化
[ [UISlider alloc] initWithFrame:CGRectMake(50.0f, 100.0f, 200.0f, 23.0f)]; 2、设置参数 最小值,最大值,当前值
self.mySlider.minimumValue = 10.0f;
self.mySlider.maximumValue = 100.0f;
self.mySlider.value = self.mySlider.minimumValue *5;
2、监听方法
[self.mySlider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventValueChanged];
六、UISegmentedControl
1、初始化
self.mySegmentedControl = [[UISegmentedControl alloc] initWithItems:[[NSArray alloc]initWithObjects: @"iPhone", @"iPad",@"iPod", @"iMac", nil]];
2、监听方法
[self.mySegmentedControl addTarget:self action:@selector(segmentChanged:) forControlEvents:UIControlEventValueChanged];
七、UINavigationController
1、初始化
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.rootViewController];
2、 UIBarButtonItem
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"完成" style: UIBarButtonItemStyleDone target:self action:@selector(performAdd:)];
八、UITabBarController
1、初始化
self.tabBarController = [[UITabBarController alloc] init];
2、 添加标签栏
[self.tabBarController setViewControllers:[[NSArray alloc] initWithObjects:self.rootNavigationController,self.secondNavigationController, nil]];
九、UILabel
1、初始化,设置文本和字体大小
self.myLabel = [[UILabel alloc] initWithFrame:CGRectMake(100.0f, 100.0f, 80.0f, 20.0f)];
self.myLabel.text = @"测试中";
self.myLabel.font = [UIFont boldSystemFontOfSize:13.0f];
十、 UITextField
1、初始化
self.myTextField = [[UITextField alloc] initWithFrame:CGRectMake(100.0f, 200.0f, 100.0f, 30.0f)];
self.myTextField.borderStyle = UITextBorderStyleBezel;
self.myTextField.textAlignment = UITextAlignmentCenter;
self.myTextField.text = @"测试中";
十一、UITextView
1、初始化
self.myTextView = [[UITextView alloc] initWithFrame:CGRectMake(100.0f, 200.0f, 100.0f, 30.0f)];
self.myTextView.text = @"测试中";
self.myTextView.font =[UIFont systemFontOfSize:15.0f];
十二、UIButton
1、初始化
self.myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
self.myButton.frame = CGRectMake(110.0f, 200.0f,100.0f, 37.0f);
[self.myButton setTitle:@"测试中" forState:UIControlStateNormal];
十三、UIImageView
1、初始化
self.myImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default.png"]];
十四、UIScrollView
1、初始化
self.myScrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
十五、UIWebView
1、初始化
self.myWebView = [[UIWebView alloc] initWithFrame:self.view.bounds];
2、加载方法
1、 loadHTMLString:baseURL:
NSString *htmlString = @"iOS 5 Programming <strong>Cookbook</strong>";
[self.myWebView loadHTMLString:htmlString baseURL:nil];
2、loadRequest:
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com"]];
[self.myWebView loadRequest:request];
1、初始化
UIAlertView *alertView =[[UIAlertView alloc] initWithTitle:@"rating" message:@"can you please rate our app" delegate:nil cancelButtonTitle:@"YES" otherButtonTitles:@"NO", nil];
1、title 显示最上面的文字
2、message title下面简序
3、delegate 委托
4、cancelButtonTitle 自定义按钮
2、监听方法
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
二、UISwitch
1、初始化
UISwitch.*uiSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(100, 160, 50, 10)];[
self.uiSwitch setOn:NO]; //设置默认值
[self.uiSwitch addTarget:self action:@selector(switchChange:) forControlEvents:UIControlEventValueChanged]; //设置监听方法
三、UIPickerView
1、初始化
[ [UIPickerView alloc]init];
self.myPicker.delegate = self;
2、为选择器添加多个组件
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
3、组件里添加多个选项
- (NSInteger) pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
4、根据组件标示显示文本数据
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
四、UIDatePicker
1、初始化
[ [UIDatePicker alloc]init];
2、设置类型
self.myDatePicker.datePickerMode = UIDatePickerModeDateAndTime;
3、监听方法
[self.myDatePicker addTarget:self action:@selector(datePickerDateChanged:) forControlEvents:UIControlEventValueChanged];
五、UISlider
1、初始化
[ [UISlider alloc] initWithFrame:CGRectMake(50.0f, 100.0f, 200.0f, 23.0f)]; 2、设置参数 最小值,最大值,当前值
self.mySlider.minimumValue = 10.0f;
self.mySlider.maximumValue = 100.0f;
self.mySlider.value = self.mySlider.minimumValue *5;
2、监听方法
[self.mySlider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventValueChanged];
六、UISegmentedControl
1、初始化
self.mySegmentedControl = [[UISegmentedControl alloc] initWithItems:[[NSArray alloc]initWithObjects: @"iPhone", @"iPad",@"iPod", @"iMac", nil]];
2、监听方法
[self.mySegmentedControl addTarget:self action:@selector(segmentChanged:) forControlEvents:UIControlEventValueChanged];
七、UINavigationController
1、初始化
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.rootViewController];
2、 UIBarButtonItem
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"完成" style: UIBarButtonItemStyleDone target:self action:@selector(performAdd:)];
八、UITabBarController
1、初始化
self.tabBarController = [[UITabBarController alloc] init];
2、 添加标签栏
[self.tabBarController setViewControllers:[[NSArray alloc] initWithObjects:self.rootNavigationController,self.secondNavigationController, nil]];
九、UILabel
1、初始化,设置文本和字体大小
self.myLabel = [[UILabel alloc] initWithFrame:CGRectMake(100.0f, 100.0f, 80.0f, 20.0f)];
self.myLabel.text = @"测试中";
self.myLabel.font = [UIFont boldSystemFontOfSize:13.0f];
十、 UITextField
1、初始化
self.myTextField = [[UITextField alloc] initWithFrame:CGRectMake(100.0f, 200.0f, 100.0f, 30.0f)];
self.myTextField.borderStyle = UITextBorderStyleBezel;
self.myTextField.textAlignment = UITextAlignmentCenter;
self.myTextField.text = @"测试中";
十一、UITextView
1、初始化
self.myTextView = [[UITextView alloc] initWithFrame:CGRectMake(100.0f, 200.0f, 100.0f, 30.0f)];
self.myTextView.text = @"测试中";
self.myTextView.font =[UIFont systemFontOfSize:15.0f];
十二、UIButton
1、初始化
self.myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
self.myButton.frame = CGRectMake(110.0f, 200.0f,100.0f, 37.0f);
[self.myButton setTitle:@"测试中" forState:UIControlStateNormal];
十三、UIImageView
1、初始化
self.myImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default.png"]];
十四、UIScrollView
1、初始化
self.myScrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
十五、UIWebView
1、初始化
self.myWebView = [[UIWebView alloc] initWithFrame:self.view.bounds];
2、加载方法
1、 loadHTMLString:baseURL:
NSString *htmlString = @"iOS 5 Programming <strong>Cookbook</strong>";
[self.myWebView loadHTMLString:htmlString baseURL:nil];
2、loadRequest:
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com"]];
[self.myWebView loadRequest:request];










