在tableviewcell里面嵌入switch控件以及如何获取switch控件数据
主要是通过cell.accessoryView来添加switch控件
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
//add a switch
UISwitch *switchview = [[UISwitch alloc] initWithFrame:CGRectZero];
[switchview addTarget:self action:@selector(updateSwitchAtIndexPath:) forControlEvents:UIControlEventValueChanged];
cell.accessoryView = switchview;
[switchview release];
}
cell.textLabel.text = [NSString stringWithFormat:@"%d", indexPath.row];
return cell;
}
.h文件中添加:
- (IBAction) updateSwitchAtIndexPath:(id) sender;
获取switch数据:
- (IBAction)updateSwitchAtIndexPath:(id)sender {
UISwitch *switchView = (UISwitch *)sender;
if ([switchView isOn])
{
//do something..
}
else
{
//do something
}
}
在tableviewcell里面嵌入switch控件以及如何获取switch控件数据的更多相关文章
- ASP.NET MVC加载用户控件后并获取其内控件值或赋值
有网友看了这篇<ASP.NET MVC加载ASCX之后,并为之赋值>http://www.cnblogs.com/insus/p/3643254.html 之后,问及Insus.NET,不 ...
- JAVA反射机制_获取字节码文件对象
是在运行状态中,对于任意一个类 (class文件),都能够知道这个类的所有属性和方法:对于任意一个对象,都能够调用它的任意一个方法和属性: 这种动态获取的信息以及动态调用对象的方法的功能称为java语 ...
- Dev控件GridView单元格绑定控件
Dev控件GridView单元格绑定控件 //文本按钮 RepositoryItemButtonEdit btnFields = new RepositoryItemButtonEdit();//创建 ...
- Cocos2d-x3.0游戏实例之《别救我》第六篇——从代码中获取UI控件
这篇的内容非常easy,获取UI控件,然后使用它. 还记得我们在UI编辑器中给三个button分别命名了吧? 如今要用上了. 笨木头花心贡献,啥?花心?不呢,是用心~ 转载请注明,原文地址: http ...
- UGUI 之获取当前控件的高度
当Canvas Scaler选择Constant Pixel Size 当前的分辨率会被被固定,可以用RectTransform类里面的.rect变量值获取 height或Width. 在次情况下获取 ...
- winfrom获取用户控件里的控件对象
如何获取用户控件里的控件对象呢,其实思路也是很简单的, 比如有一个panel 用户控件 里面有许多的其他控件. 那么要找出一个Label控件怎么找呢,好的.现在我们就开始 首先,一个foreach循环 ...
- .net dataGridView当鼠标经过时当前行背景色变色;然后【给GridView增加单击行事件,并获取单击行的数据填充到页面中的控件中】
1.首先在前台dataGridview属性中增加onRowDataBound属性事件 2.然后在后台Observing_RowDataBound事件中增加代码 protected void Obser ...
- 获取android控件的高度
问题 如何获取一个控件的长和高,相信很多朋友第一眼看见这个问题都会觉得很简单,直接在onCreate里面调用getWidth.getMeasuredWidth不就可以获得了吗,但是,事实上是并没有简单 ...
- .net获取select控件中的文本内容
.net获取select控件中的文本内容 2009-11-28 21:19小V古 | 分类:C#/.NET | 浏览1374次 <select id="SecType" st ...
随机推荐
- 安装opencv3.x卡在ICV: Downloading ippicv_linux_20151201.tgz...
参考:http://blog.csdn.net/bobsweetie/article/details/52502741 可以自己下载: ICV: Downloading ippicv_linux_20 ...
- php常见排序
public function actionQuickSort(){ $arr = ['5', '4', '3', '2', '1', '0']; $quickRes = $this->quic ...
- yii基础控制器安全验证
- 内核 platform_get_resource() 函数解析
struct resource *platform_get_resource(struct platform_device *dev, unsigned int type, un ...
- linux移植常见问题
*************1.给板子添加新的驱动**************** 一. 驱动程序编译进内核的步骤在 linux 内核中增加程序需要完成以下三项工作:1. 将编写的源代码复制 ...
- flume 实际的使用
1.No configuration found for this host:seqGenSrc bin/flume-ng agent --conf conf --conf-file conf/flu ...
- Gradle 在Eclipse中的使用
eclipse上gradle插件的安装 1)在Eclipse中选择Help -> Eclipse Marketplace…,输入buildship点击Go,然后选择Install安装Gradle ...
- pip安装插件库
升级:python -m pip install --upgrade pip 读excel:pip install xlrd 写入excel:pip install xlwt
- jvm 几个invoke 指令
invokestatic : 调用静态方法 invokespecial : 调用实例构造器<init>方法, 私有方法和父类方法 invokevirtual : 调用虚方法 invokei ...
- Process对象的其他属性:
标签(空格分隔): process join方法: 在主进程运行过程中如果想并发地执行其他的任务,我们可以开启子进程,此时主进程的任务与子进程的任务分两种情况: 情况一:在主进程的任务与子进程的任务彼 ...