2010-03-08 58 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

相关问题