首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

08-UISwitch控件两种使用方法跟监听

2013-10-12 
08-UISwitch控件两种使用方法和监听??二、通过拖拽方法使用UISwitch1、往xib文件上拖拽一个UISwitch控件。2、

08-UISwitch控件两种使用方法和监听

?

?

二、通过拖拽方法使用UISwitch

1、往xib文件上拖拽一个UISwitch控件。

08-UISwitch控件两种使用方法跟监听

2、按alt+command + return键开启Assistant Editor模式,选中UISwitch控件,按住Control键,往ViewController.h拖拽

08-UISwitch控件两种使用方法跟监听

3、选Action方式

08-UISwitch控件两种使用方法跟监听

4、.m文件中实现switchAction 。刚才动态创建的时候也用到这个方法名称,可以先注释掉刚才的。

?

- (IBAction)switchAction:(id)sender { UISwitch *switchButton = (UISwitch*)sender; BOOL isButtonOn = [switchButton isOn]; if (isButtonOn) { showSwitchValue.text = @"是"; }else { showSwitchValue.text = @"否"; }}


运行就可以了。

热点排行