ios UISwitch in a UITableView cell
来源:互联网 发布:巨杉数据库怎么样 编辑:程序博客网 时间:2024/05/16 11:36
文章来源:http://stackoverflow.com/questions/3770019/uiswitch-in-a-uitableview-cell
Setting it as the accessoryView is usually the way to go. You can set it up intableView:cellForRowAtIndexPath:
You may want to use target/action to so something when the switch is flipped. Like so:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { switch( [indexPath row] ) { case MY_SWITCH_CELL: { UITableViewCell* aCell = [tableView dequeueReusableCellWithIdentifier:@"SwitchCell"]; if( aCell == nil ) { aCell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"SwitchCell"] autorelease]; aCell.textLabel.text = @"I Have A Switch"; aCell.selectionStyle = UITableViewCellSelectionStyleNone; UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectZero]; aCell.accessoryView = switchView; [switchView setOn:NO animated:NO]; [switchView addTarget:self action:@selector(switchChanged:) forControlEvents:UIControlEventValueChanged]; [switchView release]; } return aCell; } break; } return nil;}- (void) switchChanged:(id)sender { UISwitch* switchControl = sender; NSLog( @"The switch is %@", switchControl.on ? @"ON" : @"OFF" );}
- ios UISwitch in a UITableView cell
- ios UITableview自定义cell
- IOS UITableView 移动自定义cell
- iOS开发 UITableView之cell
- IOS UITableview 的Cell 封装
- IOS-UITableView 及自定义cell
- IOS-UITableView 及自定义cell
- iOS UITableView(二)-自定义Cell
- iOS: Detecting which UIButton was pressed in a UITableView
- iOS UITableView cell accessoryType single checkmark
- ios uitableview 刷新某一个cell 或 section
- ios开发-设置UITableView/Cell背景设置
- ios UITableView中Cell的重用机制
- ios uitableview 刷新某一个cell 或 section
- ios UITableView 获取点击cell对象
- iOS—UITableView Cell重用机制
- ios uitableview 刷新某一个cell 或 section
- iOS UITableView表视图(3)自定义cell
- HTML5手机游戏将迎美好未来
- Gentoo 历程(13):qt软件部分报错,kde启动不正常
- 云的编程史(2):启蒙,进入游戏
- 读图时代来临 图片存储服务Imgur仅用5月就将月PV从10亿增加到20亿
- android-整体UI设计-(滑动导航栏+滚动页面)
- ios UISwitch in a UITableView cell
- 为什么微处理器要从单核转向多核?
- 软件需求提取,分析,升华详解
- Asp.Mvc 2.0用户登录实例讲解---(1)用户注册
- struts2 valuestrack 原理
- FAQ: How to Use AWR reports to Diagnose Database Performance Issues [ID 1359094.1]
- 《Thing In Java》 笔记1(3,4,5,6章)
- jquery使用的一些记录
- cocos2d中晃动手机切换scene(有切换特效),有时崩溃,求解