2012-05-16 47 views
0

我有一個單元格(videoCell),當未選定高度爲100像素,並且選中時擴展爲144px。在擴展後的44個像素中,我通過故事板放置了一個工具欄(detailToolbar)。在擴展單元格中啓用和禁用UI工具欄

現在,這是我的問題。如果爲工具欄啓用了用戶交互功能,則條形按鈕可以工作,並且只需關閉單元格,我就可以點擊單元格的任何原始100像素。但是,當我試圖擴展單元格時出現問題。如果我點擊未選中單元格的底部44px,則不會觸發任何內容,但只會在選擇頂部56像素時纔會響應。我假設單元格後面的detailToolbar阻止它工作。

這是我的一些代碼。我正在使用Simon Lee's tutorial來擴展單元格。

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 
// If our cell is selected, return double height 

if([self cellIsSelected:indexPath]) { 

return 144.0; 

} 

// Cell isn't selected so return single height 

return 100.0; 
} 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

// Deselect 
[self.tableView deselectRowAtIndexPath:indexPath animated:YES]; 

self.tableView.clipsToBounds = YES; 


// Store cell 'selected' state keyed on indexPath 
NSNumber *selectedIndex = [NSNumber numberWithBool:isSelected]; 
[selectedIndexes setObject:selectedIndex forKey:indexPath]; 

// This is where magic happens... 
[self.tableView beginUpdates]; 
[self.tableView endUpdates]; 
} 
+0

想通了!我已經自己回答了[這裏] [1]! [1]:http://stackoverflow.com/questions/10662376/can-not-get-uitoolbar-in-expandable-cell-to-hide/10670813#10670813 – Year3000

+0

你能刪除的一個重複的問題,然後(可能是這一個) – jrturton

回答

0

我已經自己回答了。我做了以下選擇行方法:

for(NewsCell *cell in [self.tableView visibleCells]) { 
    BOOL cellIsSelected = isSelected; 
    [cell.detailToolbar setUserInteractionEnabled:cellIsSelected]; 
} 

它的工作完美無瑕!