2016-12-27 25 views
0

我使用動畫來增加行的高度,當用戶點擊行並使用自定義附件視圖時,但當我增加高度時行附件視圖向下移動y軸y大約是行的一半,這是令人討厭的。我如何在行的頂部添加配件視圖?當我在做增加行高的動畫時,把附件轉90度。附連的代碼和圖像TableviewCell accesory view當行的高度增加(展開)時移動

此代碼動畫的實現代碼如下

  self.flag = !self.flag; 

     [tableView beginUpdates]; 
     [tableView reloadRowsAtIndexPaths:@[indexPath] 
           withRowAnimation:UITableViewRowAnimationAutomatic]; 

     [tableView endUpdates]; 

此代碼增大行高度

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath: (NSIndexPath *)indexPath{ 

    if (indexPath.section == 1){ 

    if (indexPath.row == 0) { 

     return YES == self.flag ? 70 : 44; 

    }else if (indexPath.row == 1) { 

     return YES == self.flag ? 70 : 44; 

    } 
    } 

而這個代碼接通定製附件視圖90度

self.accesoryButton.transform = CGAffineTransformMakeRotation(M_PI/2.0f); 

This image shows how the accessory moves down on y axis

回答

0
# tableViewCell.m 

- (void)layoutSubviews 
{ 
    [super layoutSubviews]; 
    CGRect adjustedFrame = self.accesoryButton.frame; 
    adjustedFrame.origin.y = self.accesoryButton.y; 
    self.accesoryButton.frame = adjustedFrame; 
} 
+1

添加一些解釋和答案,這個答案如何幫助OP在修復當前問題 –

+0

@Mike沒有工作 – frank0ch0a