2015-07-10 92 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(在表視圖數據源中),執行圖像視圖的隱藏/未隱藏活動。

相關問題