2015-01-02 30 views
1

我有一個UITableView與自定義單元格,我希望用戶能夠移動周圍的單元格。問題是,當實現代碼如下進入編輯模式,細胞移動到右邊這樣將自定義UITableViewCells動畫在編輯模式左側(而不是右側)

enter image description here

但我希望他們向左移動,因此不會阻止的順序控制的細胞

我看過一堆這樣的問題,但我還沒有找到任何答案。有沒有簡單的方法來做到這一點,還是我必須自己寫動畫?

另外,有人可以告訴我爲什麼會發生這種情況嗎?

注意

這是委託方法我加做這個

- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
return YES; 
} 

而且,是的,我沒有添加自定義視圖定製細胞含量的觀點

感謝

回答

1

嘗試覆蓋UITableViewCell的setEditing:animated:函數來創建自定義動畫,並按照需要的方向移動控件。

例如

- (void)setEditing:(BOOL)editing animated:(BOOL)animated 
{ 
    [super setEditing:editing animated:animated]; 

    if (animated) { 
     [UIView animateWithDuration:0.5 delay:0.0 
          options:UIViewAnimationOptionCurveEaseInOut animations:^{ 
      CGRect titleFrame = self.titleLabel.frame; 

      if (editing) { 
       [self.titleLabel setFrame:CGRectMake(15, titleFrame.origin.y, titleFrame.size.width, titleFrame.size.height)]; 
      } else { 
       [self.titleLabel setFrame:CGRectMake(25, titleFrame.origin.y, titleFrame.size.width, titleFrame.size.height)]; 

      } 
     }completion:nil]; 
    } 
} 
+0

我這樣做。用戶界面看起來不錯,但重新排序控制不起作用 – MendyK

+0

當你使用它時,重新排序控制停止工作? – rakeshbs

+0

是的。它實際上消失了你的方式 – MendyK

相關問題