iOS中UITableView单选标记的实现
来源:互联网 发布:模拟炒股软件 推荐 编辑:程序博客网 时间:2024/04/29 04:37
摘录自《iPhone3开发基础教程》第202页:
#pragma mark -
#pragma mark Table Delegate Methods
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
int newRow = [indexPath row];
int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1;
if(newRow != oldRow)
{
UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
newCell.accessoryType = UITableViewCellAccessoryCheckmark;
UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:lastIndexPath];
oldCell.accessoryType = UITableViewCellAccessoryNone;
lastIndexPath = indexPath;
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
运行结果:要是点的是同一行,选中标记就不变。要是另外选择了一行,该行就设上“对钩”,原来那一行就没有标记了。
转自: http://hi.baidu.com/jt_one/item/bc915f31e6e12e21b2c0c5eb
- iOS中UITableView单选标记的实现
- iOS开发笔记-UITableView的单选
- iOS如何利用UITableView实现单选效果
- [ios] UITableVIew单选效果
- iOS学习 UITableView 单选
- iOS中使用UITableView的实现向左拉实现删除
- iOS中UITableview实现跨区域拖动效果的实现
- IOS中UITableView异步加载图片的实现
- IOS中UITableView异步加载图片的实现
- iOS中表格(UITableView)嵌套表格的简单实现
- 【iOS】UITableView Cell自定义单选功能
- iOS单选——UITableView 写的列表单选
- UITableView 实现类似btn单选功能
- iOS UITableView 中局部刷新实现方式
- iOS开发:UITableview的多选功能实现
- iOS关于在UITableView中,实现多个cell中不同的倒计时实现
- iOS 关于在UITableView中,实现多个cell中不同的倒计时实现
- iOS关于在UITableView中,实现多个cell中不同的倒计时实现
- 树的最大路径和 Binary Tree Maximum Path Sum
- HDU3988 Harry Potter and the Hide Story
- Q2.5
- pygtk
- SSH中.动态获取spring IoC容器中管理的bean,dao
- iOS中UITableView单选标记的实现
- HOJ 1003 Max Sum 解题报告
- 内存分区
- JAVA 利用反射机制查询数据库返回相应对象
- startActivityForResult用法详解
- Android使用SurfaceView实现墨迹天气的风车效果
- BITACM 1044 A^B mod C
- 日期对象
- json基础