2011-12-02 71 views

回答

1

創建一個UITableViewCell的子類。將您的UITextFieldUITextField(取決於您的解決方案)添加到contentView中,並將其隱藏起來。覆蓋`-setSelected:動畫:」方法:

- (void)setSelected:(BOOL)selected animated:(BOOL)animated 
{ 
    [super setSelected:selected animated:animated]; 
    if (animated) { 
    // using old-school UIView animation support to fade in/out controls, 
    // block-based much easier, but only 4.0 or greater 
    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; 
    self.textLabel.alpha = (selected) ? 0.0 : 1.0; 
    self.detailTextLabel.alpha = (selected) ? 0.0 : 1.0; 
    // assumed you added a UITextView 'textView' ivar 
    self.textView.alpha = (selected) ? 1.0 : 0.0; 
    [UIView commitAnimations]; 
    } 
    else { 
    self.textLabel.hidden = selected; 
    self.detailTextLabel.hidden = selected; 
    self.textView.hidden = !selected; 
    } 
} 

- (void)animationDidStop:(NSString *)animationID finished:(BOOL)finished context:(void *)context 
{ 
    self.textLabel.hidden = self.selected; 
    self.detailTextLabel.hidden = self.selected; 
    self.textView.hidden = !self.selected; 
} 
0

構建cellForRowAtIndexPath:中的正常細胞。在didSelectrowAtIndexPath:上,執行tableview重新加載。

使用全局標誌跟蹤行選擇,並且在構造單元之前每次都檢查標誌並確定要加載的單元類型。

0

您可能會發現簡單隨時使用自定義表格視圖單元格,但是當它被選中(例如具有不同的外觀時的setSelected是叫你可以改變你的子視圖或顏色或其他)。

相關問題