2010-03-08 38 views
2

的_some_空的部分如果我有一個UITableView在編輯模式下,W /重新排序開啓,看來我不能移動了一些(但不是全部)細胞進入一些(但不所有)空白部分。例如,如果我有這樣的佈局:不能重新排序的UITableViewCell到一個UITableView

Section 1 
    apple 
    banana 
Section 2 
    doberman 
Section 3 
Section 4 

然後我可以移動「杜賓」到在第1任意插槽(除了「香蕉」之後),但我不能將其移動到第3或4在所有。

在另一方面,我可以移動「蘋果」 &「香蕉」成部的第2(除了「杜賓」之後),我可以將其移動到第3節,但不進入部分4

是什麼賦予了?這看起來像是越野車行爲。人們如何解決它?蘋果是否意識到這個錯誤?

+0

是否試圖將細胞移動到這些部分時targetIndexPathForMoveFromRowAtIndexPath方法火? – DyingCactus 2010-03-09 00:02:59

+0

@DyingCactus:它沒有。 – 2011-05-26 11:06:53

回答

2

是啊,這是一個蘋果的bug。我跟蘋果談過話,用我的一張「支持票」來告訴我這是他們的壞話。

我還沒有破解它周圍,從明顯的許多部分表模型到只能有一個單節,和模型「節頭」爲風格的表視圖細胞模型。

愚蠢的蘋果......

2

我用另一個黑客:創建與編輯模式的空單元格(不可見backgroundView)虛擬最後一節。有了這個,我可以保留部分/行組織,並且重新排序工作非常棒,即使是「最後」部分。

另一種方式,就是有,至少,相同高度的細胞部分頁腳。在這種情況下,單元格可以越過最後一節的最後一個單元格。

0

Sirdek是正確的。只需將以下代碼複製到您的UITableViewDelegate/UITableViewDataSource。

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section 
{ 
    NSInteger lastSection = [self numberOfSectionsInTableView:tableView] - 1; 
    NSInteger lastRow = [self tableView:tableView numberOfRowsInSection:lastSection] - 1; 
    CGFloat height = [self tableView:tableView heightForRowAtIndexPath:[NSIndexPath indexPathForRow:lastRow inSection:lastSection]]; 

    return (section == lastSection ? [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, height)] autorelease] : nil); 
} 


- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section 
{ 
    NSInteger lastSection = [self numberOfSectionsInTableView:tableView] - 1; 
    NSInteger lastRow = [self tableView:tableView numberOfRowsInSection:lastSection] - 1; 
    CGFloat height = [self tableView:tableView heightForRowAtIndexPath:[NSIndexPath indexPathForRow:lastRow inSection:lastSection]]; 

    return (section == lastSection ? height : 0); 
} 
+0

在最後一節中添加節頁腳是否也解決了無法定位其他節中最後一行的問題? – Matthew 2011-06-18 08:34:55

相關問題