tableview点击变cell背景颜色问题
功能就是多选效果,点击其中一个 背景变色,在点击就回变回白色,求教
1,一共18个数组,点击第一个cell改变颜色的时候第15个也自动变更颜色,第二个16个也回同事变色,第三个17个也回,
代码如下
1,一共18个数组,点击第一个cell改变颜色的时候第15个也自动变更颜色,第二个16个也回同事变色,第三个17个也回,
代码如下
[code=objc]@interface fivetableview ()
@end
@implementation fivetableview
@synthesize dlists;
@synthesize dellist;
NSInteger i;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
dellist=[[NSMutableArray alloc]initWithCapacity:30];
dlists=[[NSMutableArray alloc] initWithCapacity:30 ];
[dlists addObject:@"大众化的"];
[dlists addObject:@"线条硬朗的"];
[dlists addObject:@"流线型的"];
[dlists addObject:@"大气的"];
[dlists addObject:@"时尚的"];
[dlists addObject:@"简约的"];
[dlists addObject:@"有力量感的"];
[dlists addObject:@"张扬的"];
[dlists addObject:@"霸气的"];
[dlists addObject:@"动感的"];
[dlists addObject:@"稳重的"];
[dlists addObject:@"优雅的"];
[dlists addObject:@"粗犷的"];
[dlists addObject:@"创新的"];
[dlists addObject:@"中性的"];
[dlists addObject:@"活力的"];
[dlists addObject:@"经典的"];
NSLog(@"%d",[dlists count]);
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [dlists count];
//return [dlists count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"MyCell4";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
NSInteger row = [indexPath row];
cell.textLabel.text = [self.dlists objectAtIndex:row];
NSLog(@"row=%d",row);
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.backgroundColor = [UIColor redColor];
@end
[/code]
...全文
相关推荐
UITableViewCell在编辑状态下背景颜色的修改方法
主要给大家介绍了关于UITableViewCell在编辑状态下背景颜色的修改方法,文中通过示例代码介绍的非常详细,对大家具有一定的参考学习价值,需要的朋友们下面跟着小编一起来学习学习吧。
Swift 去除 TableView 多余的空Cell中的横线的方法
主要介绍了Swift 去除 TableView 多余的空Cell中的横线的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
并列tableview
一种并列的tableview
iphone开发实例 TableView 02
02-Changing BG 修改tableview背景
Swift TableView实现冻结窗格功能
主要为大家详细介绍了Swift TableView实现冻结窗格功能,具有一定的参考价值,感兴趣的小伙伴们可以参考一下


