2013-05-30 59 views
0

我有一個自定義的UITableViewCell,裏面有一些擴展菜單。 細胞與菜單如下:UITableViewCell - 滾動停止後的子視圖重新佈局

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

因爲細胞被重新使用,我需要關閉菜單(如果它的擴展),在小區出列,所以新出隊的細胞會出現菜單關閉。

問題是,直到表視圖滾動停止後,出列單元格中的菜單纔會關閉。 有沒有什麼辦法可以在單元退出後關閉菜單?

謝謝。

回答

0

問題解決。 我不得不使用「當前的NSRunLoop模式」:

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

嘗試在您的手機中使用方法-(void)prepareForReuseHere是它的描述。

0

這很難說是一個沒有代碼的問題進行分析,但你可以使用一個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