IOS-常见控件用法例子(一)
来源:互联网 发布:逗斗车 知乎 编辑:程序博客网 时间:2024/06/09 14:42
这部分主要展示了这些控件的用法:UISwitch, UISlider, UIStepper, UIToolbar, UISegmentedControl
因为偷懒,全部的控件共用一个事件处理函数。
h文件
//// ViewController.h// UICtrl//// Created by God Lin on 14/11/30.// Copyright (c) 2014年 arbboter. All rights reserved.//#import <UIKit/UIKit.h>@interface ViewController : UIViewController{ IBOutlet UITextField* _textInfo; IBOutlet UISwitch* _switchText; IBOutlet UISlider* _sliderText; IBOutlet UIStepper* _stepperText; IBOutlet UIToolbar* _toolbarView; IBOutlet UISegmentedControl* _segmentedBKColor;}@property (nonatomic, retain) UITextField* _textInfo;@property (nonatomic, retain) UISwitch* _switchText;@property (nonatomic, retain) UISlider* _sliderText;@property (nonatomic, retain) UIStepper* _stepperText;@property (nonatomic, retain) UIToolbar* _toolbarView;@property (nonatomic, retain) UISegmentedControl* _segmentedBKColor;-(IBAction)onCtrl:(id)sender;@end
m文件
//// ViewController.m// UICtrl//// Created by God Lin on 14/11/30.// Copyright (c) 2014年 arbboter. All rights reserved.//#import "ViewController.h"@interface ViewController ()@end@implementation ViewController@synthesize _textInfo;@synthesize _switchText;@synthesize _sliderText;@synthesize _stepperText;@synthesize _toolbarView;@synthesize _segmentedBKColor;-(IBAction)onCtrl:(id)sender{ if (sender == _switchText) { if(_switchText.isOn) { _textInfo.text = @"Switch is On"; } else { _textInfo.text = @"Switch is Off"; } } else if(sender == _sliderText) { NSString* strSlider = [[NSString alloc] initWithFormat:@"%.2f", _sliderText.value]; _textInfo.text = strSlider; [strSlider release]; } else if(sender == _stepperText) { NSString* strText = [[NSString alloc] initWithFormat:@"%.2f", [_stepperText value]]; _textInfo.text = strText; [strText release]; } else if(sender == _segmentedBKColor) { UIColor* bkColor[3] = {[UIColor whiteColor], [UIColor greenColor], [UIColor blueColor]}; [self.view setBackgroundColor:bkColor[[_segmentedBKColor selectedSegmentIndex]]]; }}- (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.}-(void)dealloc{ [_textInfo release]; [_switchText release]; [_sliderText release]; [_stepperText release]; [_toolbarView release]; [_segmentedBKColor release]; [super dealloc];}@end
0 0
- IOS-常见控件用法例子(一)
- iOS开发-GCD 常见用法一(延迟执行)
- 常见控件用法.
- iOS开发多线程篇—GCD的常见用法(一)
- Linux find常见用法例子
- iOS常见控件设置
- 常见控件的使用方法(一)
- Android常见控件【一】
- 常见的iOS用法
- ios常用控件(一)
- freemarker常见的一些用法(一)
- 反编译常见工具及用法(一)
- C++string类常见用法(一)
- 表达式-Thymeleaf常见用法(一)
- Opencv常见用法和常见错误(一)
- 常见Flex控件用法剖析
- 常见Flex控件用法剖析
- DevExpress 控件 GridControl常见用法
- 循环-06. 统计一行文本的单词个数(15)
- 分数加减法(POJ3979)
- 黑马程序员——java接口与抽象类的区别之缺省适配模式
- C语言程序设计教程之结构体与共用体
- 第24天 BIT
- IOS-常见控件用法例子(一)
- Mac Word的显示问题
- HTTP协议头部与Keep-Alive模式详解
- android组件搭配
- 循环-07. 爬动的蠕虫(15)
- poj 2777 Count Color (成段更新+区间求和)
- 国外intel总结的比较全的Android 3D游戏引擎介绍
- 杭电OJ(HDOJ)1032题:The 3n + 1 problem(穷举,水题)
- windb symbols