自定义UITableView中的删除按钮 [英] Customize the delete button in UITableView
本文介绍了自定义UITableView中的删除按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我具有滑动删除" TableViewCell
的功能.我想自定义删除按钮.
I have the functionality for "Swipe to delete" the TableViewCell
. I want to customize the Delete button.
这是否可行,以及如何访问删除按钮?
Is this possible, and how to access the Delete button ?
推荐答案
用户执行滑动操作时将调用此方法
只需将其放入CustomCell
- (void)willTransitionToState:(UITableViewCellStateMask)state
{
[super willTransitionToState:state];
if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateShowingDeleteConfirmationMask)
{
for (UIView *subview in self.subviews)
{
if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"])
{
UIImageView *deleteBtn = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 64, 33)];
[deleteBtn setImage:[UIImage imageNamed:@"arrow_left_s11.png"]];
[[subview.subviews objectAtIndex:0] addSubview:deleteBtn];
}
}
}
}
您不应尝试这样做,不应更改Apple的默认视图.
这篇关于自定义UITableView中的删除按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文