UITableViewCell - 滚动停止后的子视图重新布局

问题描述:

我有一个自定义的UITableViewCell,里面有一些扩展菜单。 细胞与菜单如下:UITableViewCell - 滚动停止后的子视图重新布局

+--------------+ 
|(>)--(a)--(b) | (cell#1 - expanded) 
+--------------+ 
+--------------+ 
|(<)   | (cell#2 - not expanded) 
+--------------+ 
> = root menu button 
a = expanded item 1 
b = expanded item 2 

因为细胞被重新使用,我需要关闭菜单(如果它的扩展),在小区出列,所以新出队的细胞会出现菜单关闭。

问题是,直到表视图滚动停止后,出列单元格中的菜单才会关闭。 有没有什么办法可以在单元退出后关闭菜单?

谢谢。

问题解决。 我不得不使用“当前的NSRunLoop模式”:

[self performSelector:@selector(animateItemToStartPoint:) 
       withObject:dictionary 
       afterDelay:animation.delayBetweenItemAnimation * x 
       inModes:@[[[NSRunLoop currentRunLoop] currentMode], NSDefaultRunLoopMode]]; 

尝试在您的手机中使用方法-(void)prepareForReuseHere是它的描述。

这很难说是一个没有代码的问题进行分析,但你可以使用一个isMenuOpened属性自定义单元格和closeMenu像这样

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *CellIdentifier = @"Cell"; 
    YourCustomCell*cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[YourCustomCell alloc] initWithStyle:UITableViewCellStyleDefault 
            reuseIdentifier:CellIdentifier]; 
     //perform init setup here or other ops 
    } 
    else { 
     if(cell.isMenuOpened) { 
      [cell closeMenu]; 
     } 
     //do other setup here, set text and other stuffs 
    } 

    return cell 
} 

方法,建议你cellForRow方法实现这个通过xexe是正常的,当您使用轻属性更改(如alpha)和与内容无关的属性时,出于性能原因。

+0

这没有帮助。 这里是视频的问题: http://www.youtube.com/watch?v=xCR0-DfvkT4 这里是演示项目: https://dl.dropboxusercontent.com/u/2261256/development/ menuTest.zip – OldFox