iOS如何利用UITableView实现单选效果
来源:互联网 发布:西安网络推广咨询电 编辑:程序博客网 时间:2024/06/13 01:20
众所周知,iOS没有单选的控件,那么我们如何在ios上实现单选的效果呢?通过查资料我发现,可以通过改装下UITableView的多选,从而实现单选。
首先将UITableView设为多选模式
_tableView.allowsMultipleSelectionDuringEditing = YES; [_tableView setEditing:YES animated:YES];
那么如何实现单选呢,当然就是在用户选中某一行的时候,把他上一行选中的效果删掉就可以啦!具体要在下面的回调函数中增加如下代码。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ // 取消前一个选中的,就是单选啦 //_index设为全局变量出初始化为-1, NSIndexPath *lastIndex = [NSIndexPath indexPathForRow:_index inSection:0]; UITableViewCell *lastCell = [tableView cellForRowAtIndexPath:lastIndex]; lastCell.accessoryType = UITableViewCellAccessoryNone; // 选中操作 UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; cell.accessoryType = UITableViewCellAccessoryCheckmark;// // // 保存选中的行 _index = indexPath.row; //afterDelay为延迟多少删除上次的选中效果 [_tableView performSelector:@selector(deselectRowAtIndexPath:animated:) withObject:lastIndex afterDelay:.0];}
0 0
- iOS如何利用UITableView实现单选效果
- [ios] UITableVIew单选效果
- iOS中UITableView单选标记的实现
- iOS学习 UITableView 单选
- 【iOS】UITableView实现的瀑布流效果
- ListView利用CheckedTextViewr实现条目单选效果
- iOS开发笔记-UITableView的单选
- 【iOS】UITableView Cell自定义单选功能
- IOS 如何实现UITableView的划动删除
- iOS中UITableview实现跨区域拖动效果的实现
- UITableView 实现类似btn单选功能
- iPhone UITableView(利用UITableView实现平滑的九宫格效果)
- iPhone UITableView(利用UITableView实现平滑的九宫格效果)
- IOS 之 UITableView 实现点击展开裂缝效果
- IOS 开发使用UITableView实现抽屉打开关闭效果
- 如何利用RadioButtonList实现datagrid列的单选
- 如何利用RadioButtonList实现datagrid列的单选
- 如何利用RadioButtonList实现datagrid列的单选
- mySQL大量数据中去重复查询
- cassandra ALLOW FILTER 的工作原理
- Leetcode52: Delete Node in a Linked List
- 无警告C语言编译断言
- html tab效果实现
- iOS如何利用UITableView实现单选效果
- Fiddler2中文乱码问题
- JNI中jstring操作
- iOS懒加载
- lipo 命令
- Linux系统内存监控全面讲解:free命令 http://os.51cto.com/art/201004/193160.htm
- [转][技巧]linux命令行解压小技巧一例
- 【转】C#中WinForm程序退出方法技巧总结
- DataTables的使用