2012-08-08 18 views
1

我在我的tableview中定製了單元格。當可用視圖處於編輯模式時,請選擇。圓角的刪除圖標出現在單元格的內容上。自定義UITableCell:爲什麼刪除圖標出現在單元格視圖的內容上?

如何將內容移至右側,以便爲該紅色小圓角按鈕創建位置。

在自定義單元格視圖layoutsubview應該發生的事情。 細胞視圖的哪個子視圖應該調整大小?

在此先感謝

請看看我當前的代碼

- (void) layoutSubviews 
{ 
[super layoutSubviews]; 

CGFloat width = self.width - _productImage.right - 20.f; 

if (self.accessoryView) 
{ 
    width -= self.accessoryView.width; 
} 

_productName.width  = width; 
_productDescription.width = width; 
_productPrice.width  = width; 

[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationBeginsFromCurrentState:YES]; 
[UIView setAnimationDuration:3.0f]; 

for (UIView *subview in self.subviews) { 


    if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) { 
     CGRect newFrame = self.contentView.frame; 
     self.contentView.frame = CGRectMake(40, self.contentView.frame.origin.y, newFrame.size.width, newFrame.size.height); 
    } 
    else if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellEditControl"]) { 
     CGRect newFrame = self.contentView.frame; 
     self.contentView.frame = CGRectMake(40, self.contentView.frame.origin.y, newFrame.size.width, newFrame.size.height); 
    } 
    else if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellReorderControl"]) { 
     CGRect newFrame = self.contentView.frame; 
     self.contentView.frame = CGRectMake(40, self.contentView.frame.origin.y, newFrame.size.width, newFrame.size.height); 
    } 
} 
[UIView commitAnimations]; 

}

回答

1

您可以檢查tableview.isEditing財產。

如果是YES ,然後更新cell.contentView幀的x差否則使用默認的。

希望這是你需要的。

享受編碼:)

+0

我應該在哪裏檢查?在細胞視圖?或其他人我在自定義單元格中執行了tablview控制器 – 2012-08-08 10:54:58

+0

:如果在layoutsubviews中self.isEditing,然後重新定位uielements。感謝提示 – 2012-08-09 06:44:53

+0

M很高興它可以幫助你...你可以請投票相同..在此先感謝.. :) – Mrunal 2012-08-10 06:19:47

相關問題