TableView中单选的实现
来源:互联网 发布:福昕编辑器mac 编辑:程序博客网 时间:2024/05/16 15:07
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//实现单选
self.lastIndexPath=self.currentIndexPath;
self.currentIndexPath=indexPath;
if (self.lastIndexPath)
{
[tableView reloadRowsAtIndexPaths:@[self.lastIndexPath]withRowAnimation:UITableViewRowAnimationAutomatic];
}
[tableView reloadRowsAtIndexPaths:@[self.currentIndexPath]withRowAnimation:UITableViewRowAnimationAutomatic];
NSLog(@"%@",[[self.areaobjectAtIndex:indexPath.row]objectForKey:@"State"]);
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell=[tableViewdequeueReusableHeaderFooterViewWithIdentifier:@"cell"];
if (!cell)
{
cell = [[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:@"cell"];
// ?? cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"cell"] autorelease];
}
cell.imageView.image = [UIImageimageNamed:@"PNG-0993"];
//添加细节指示按钮
cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;
NSString *state = [[self.areaobjectAtIndex:indexPath.row]objectForKey:@"State"];
cell.textLabel.text = state;
//实现单选
if ([self.currentIndexPathisEqual:indexPath])
{
cell.accessoryType=UITableViewCellAccessoryCheckmark;
UILabel *label=[[UILabelalloc]initWithFrame:CGRectMake(200,0, 100, 30)];
label.backgroundColor = [UIColorblueColor];
label.text=@"123";
label.textColor=[UIColoryellowColor];
[cell.contentViewaddSubview:label];
}
else
{
cell.accessoryType=UITableViewCellAccessoryNone;
}
return cell;
}
- TableView中单选的实现
- 横向TableVIew的实现
- tableView的底层实现
- 实现可折叠的分组tableview
- tableview上下刷新的实现
- tableView下拉框的实现
- cocos2dx3.10的TableView的实现
- 利用DTGridView实现横向滚动的tableview
- 利用DTGridView实现横向滚动的tableview
- 利用DTGridView实现横向滚动的tableview
- TableVIew实现类似于电话本的首字母索引
- iOS tableview 实现简单的搜索功能
- iOS tableview 实现简单的搜索功能
- iOS tableview 实现简单的搜索功能
- 分离tableview的datasource , 实现ViewController “瘦身”
- IOS 嵌套实现分页的TableView
- 为TableView的行实现双击事件
- 一种可展开伸缩的tableView实现
- imageview圆角的实现
- 如何实现将'one,two,three,four,five' 分别打印
- Difference between List and Set in Java Collection
- 开发者必备网站
- JAVA抓取网页的图片,JAVA利用正则表达式抓取网站图片
- TableView中单选的实现
- Java__凯撒密码 非常详细
- 学习网址
- /usr/bin/ld: cannot find -lc
- css 中的background:transparent到底是什么意思有什么作用
- 析构函数和Dispose的使用区别
- C/C++中的i18n(wcstombs和mbstowcs使用)
- 云计算——大规模主机安装PXE
- uva 11292 Dragon of Loowater