2015-07-10 90 views
0

在我的应用程序中,我在一个地方显示UIImage和标签表格视图单元格。它工作正常。同时点击行我尝试隐藏一个UIImage视图并显示另一个UIImage视图。隐藏的UIImageView,同时点击表格视图单元格

代码,我尝试是

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *simpleTableIdentifier = @"AddFrdsGroup"; 
    AddFriendsCell *cell = (AddFriendsCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; 
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"AddFriendsCell" owner:self options:nil]; 
    cell = [nib objectAtIndex:0]; 
    if(cell.chkAddFrdsYes.hidden==YES) 
    { 
     cell.chkAddFrdsNo.hidden=YES; 
     cell.chkAddFrdsYes.hidden=NO; 
    } 
    else 
    { 
     cell.chkAddFrdsNo.hidden=YES; 
     cell.chkAddFrdsYes.hidden=NO; 
    } 
} 
+1

解释一点点? –

+0

我是绑定表视图单元格到表视图。它在页面加载时工作正常。之后,如果点击单元格,它想要隐藏一个UIImage视图并显示其他UIImage视图。 –

+0

为什么你同时使用'[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]'和'NSArray * nib = [[NSBundle mainBundle] loadNibNamed:@“AddFriendsCell”owner:self options:nil]; cell = [nib objectAtIndex:0];'in didSelectRow? –

回答

1

您的消息还不是很清楚,但我会尽力帮助你与我能理解。 您需要获取您选择的单元格,而不是创建或退出新单元格。 改为尝试此操作。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    AddFriendsCell *cell = (AddFriendsCell *)[tableView cellForRowAtIndexPath:indexPath]; 
    if(cell.chkAddFrdsYes.hidden==YES) 
    { 
     cell.chkAddFrdsNo.hidden=YES; 
     cell.chkAddFrdsYes.hidden=NO; 
    } 
    else 
    { 
     cell.chkAddFrdsNo.hidden=YES; 
     cell.chkAddFrdsYes.hidden=NO; 
    } 
} 
0

在didSelectRowAtIndexPath方法的方法,在保存实例变量/属性选择的行/细胞的indexPath和呼叫表视图的reloadData方法。在tableView:cellForRowAtIndexPath:implementation(在表视图数据源中),执行图像视图的隐藏/未隐藏活动。

相关问题