点击UITableViewCell 来回切换内容
来源:互联网 发布:2016年最火的软件 编辑:程序博客网 时间:2024/04/26 14:15
@interface ViewController ()
@property (nonatomic,weak) UITableView *tableView;
@property (nonatomic,strong) NSArray *cellForNoClickedArray;//未点击数据源
@property (nonatomic,strong) NSArray *cellForClickedArray;//点击数据源
@property (nonatomic,strong) NSMutableArray *selectedStatusArray;//被点击状态的修改
@end
@implementation ViewController
-(UITableView *)tableView{
if (!_tableView) {
UITableView *tb = [[UITableViewalloc] initWithFrame:CGRectMake(0,0, self.view.frame.size.width,self.view.frame.size.height)];
tb.delegate = self;
tb.dataSource = self;
[self.viewaddSubview:tb];
_tableView = tb;
}
return_tableView;
}
- (void)viewDidLoad {
[superviewDidLoad];
[selftableView];
self.cellForNoClickedArray =@[@"a",@"b",@"c",@"d",@"e",@"f",@"g",@"h",@"i",@"g"];
self.cellForClickedArray =@[@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"G"];
self.selectedStatusArray = [NSMutableArrayarrayWithArray:@[@"0",@"0",@"0",@"0",@"0",@"0",@"0",@"0",@"0",@"0"]];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 60.f;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
returnself.cellForNoClickedArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *listCell =@"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:listCell];
if (cell == nil) {
cell = [[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:listCell];
}
if ([self.selectedStatusArray[indexPath.row]isEqualToString:@"0"]) {
cell.textLabel.text =self.cellForNoClickedArray[indexPath.row];
cell.textLabel.textColor = [UIColorredColor];
}else{
cell.textLabel.text =self.cellForClickedArray[indexPath.row];
cell.textLabel.textColor = [UIColorgreenColor];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if([self.selectedStatusArray[indexPath.row]isEqualToString:@"0"]){
[self.selectedStatusArrayreplaceObjectAtIndex:indexPath.rowwithObject:@"1"];
}else{
[self.selectedStatusArrayreplaceObjectAtIndex:indexPath.rowwithObject:@"0"];
}
[self.tableViewreloadData];
}
- 点击UITableViewCell 来回切换内容
- 点击图片来回切换图片--2张来回切换
- 点击菜单背景颜色来回切换
- Android 点击按钮实现来回切换背景图和文字
- 点击菜单栏实现内容切换
- 两个图片来回切换
- JS来回切换路径
- JS 来回切换图片
- 页面来回切换js
- 线程的来回切换
- android中Imagebutton实现两张图片之间的点击来回切换
- jquery点击图标来回切换的几种方法(如开关按钮)
- div 内容点击切换的小技巧
- ViewPager滑动和点击切换内容
- 点击新闻标题,内容随着标题切换
- div 内容点击切换的小技巧
- Fragmen直接来回切换deno
- ImageButton开关背景图片来回切换
- Android学习笔记十之Android基础UI一
- 基础总结篇之一:Activity生命周期
- 把一个库开源,你该做些什么
- WIKI服务搭建-JSPWIKI
- activemq简介
- 点击UITableViewCell 来回切换内容
- JTable响应鼠标双击的事件, 并且希望能获得鼠标事件发生在Table中行列位置
- MyBatis学习总结(二)——使用MyBatis对表执行CRUD操作
- Java NIO 详解(二)
- CSUOJ 1120 最长公共上升子序列
- 最牛逼android上的图表库MpChart(二) 折线图
- HTML 事件属性
- Eclipse Class Decompiler——Java反编译插件
- 【报错】 ClassNotFoundException: javax.transaction.Synchronization