gpt4 book ai didi

iphone - 在 UITableView 单元格中编辑时自定义删除按钮

转载 作者:行者123 更新时间:2023-12-03 18:17:17 25 4
gpt4 key购买 nike

我已经浏览过this question显示以下代码:

-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{
return @"Sagar";
}

如果我想要自定义图像而不是默认的红色按钮怎么办?

最佳答案

在自定义单元格中实现此方法

- (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:@"delete.png"]];
[[subview.subviews objectAtIndex:0] addSubview:deleteBtn];
[deleteBtn release];
}
}
}
}

关于iphone - 在 UITableView 单元格中编辑时自定义删除按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1615469/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com