早教吧 育儿知识 作业答案 考试题库 百科 知识分享

如何取得TALBEVIEW中cell.backgroundView中的某个对象?我的代码如下:-(UITableViewCell*)tableView:(UITableView*)tableViewcellForRowAtIndexPath:(NSIndexPath*)indexPath{……//添加CELL的背景图片UIImageView*vbgCell=[[U

题目详情
如何取得TALBEVIEW中cell.backgroundView 中的某个对象?我的代码如下:- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{…… //添加CELL的背景图片 UIImageView *vbgCell = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,228,40)]; vbgCell.image = [UIImage imageNamed:@"sLine_playlist.png"]; //添加CELL选中时的背景图片 UIImageView *vbgCellB = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,228,40)]; vbgCellB.image = [UIImage imageNamed:@"sLine_playlistB.png"]; [cell.backgroundView addSubview:vbgCellB]; [cell.backgroundView addSubview:vbgCell];……}//选中单元格所产生事件-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ //伪码如下 cell.backgroundView.其中的一个对象.alpha = 0; 这里我想获取CELL中包含对象的数组,然后得到其中指定的一个对象进行修改设置,请问应该怎么写? }
▼优质解答
答案和解析
OK,我现在找到方法了://添加CELL的背景图片 UIImageView *vbgCell = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,228,40)]; vbgCell.image = [UIImage imageNamed:@"sLine_playlist.png"]; cell.backgroundView = vbgCell; UIImageView *vbgCellB = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,228,40)]; vbgCellB.image = [UIImage imageNamed:@"sLine_playlist.pngB"]; cell.selectedBackgroundView = vbgCellB;不过在点击的时候并没有显示选中时的背景图片。