2010-07-20 19 views
0

我面對一個非常奇怪的問題與editingStyleForRowAtIndexPath方法。我打算改變可編輯單元格的外觀。它工作正常,但是當我滾動表格,我沒有得到editStyleForRowAtIndexPath委託方法中的表格單元格指針。所以新的單元格不會獲得自定義外觀。提前editingStyleForRowAtIndexPath滾動問題

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

    // get tablviewcell pointer 
    UITableViewCell* pCell = [tableView cellForRowAtIndexPath:indexPath]; // <- not getting the pointer when scrolling the table and new cells come up 

     //Changin cell appearance here ... 




} 

謝謝 -

我現在用這個!

回答

1

我認爲表格視圖可能調用此方法之前,它將一個單元格分配給給定的索引路徑。定製表格視圖單元格更可靠的方法是覆蓋-tableView:willDisplayCell:forRowAtIndexPath :.您可以在那裏測試單元格的editingStyle屬性並相應地執行操作。

+1

你好Costique, 我剛查了這一點,並發現該方法在此順序執行 1) - (UITableViewCell的*)的tableView:(UITableView的*)的tableView的cellForRowAtIndexPath:(NSIndexPath *)indexPath 2) - (UITableViewCellEditingStyle)的tableView :(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath 3) - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 但我無法獲得第三種方法本身的單元格。 請幫忙!! – Saurabh 2010-07-20 12:42:40

+0

奇怪。表視圖在-tableView中作爲單元參數發送了什麼(第二個):willDisplayCell:forRowAtIndexPath:?該方法是否被調用?如果沒有,請檢查實現該方法的對象是否實際上是表視圖的委託。 – Costique 2010-07-20 13:10:14