2018-05-08 [OC] UITableViewCellReorderControl 改变默认图片

方法一:改在Controller里面

参考:ios - Reorder tableview cell with a custom button - postion and image

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.tableView.editing)
    {
        for (UIView * view in cell.subviews)
        {
            if ([NSStringFromClass([view class]) rangeOfString: @"UITableViewCellReorderControl"].location != NSNotFound)
            {
                for (UIView * subview in view.subviews) {
                    if ([subview isKindOfClass: [UIImageView class]])
                    {
                        ((UIImageView *)subview).image = [UIImage imageNamed: @"accessory_next"];
                    }
                }
            }
        }
    }
}

方法二:改在UITableViewCell里面

参考:# Change default icon for moving cells in UITableView

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

    if (editing) {

        for (UIView * view in self.subviews) {
            if ([NSStringFromClass([view class]) rangeOfString: @"Reorder"].location != NSNotFound) {
                for (UIView * subview in view.subviews) {
                    if ([subview isKindOfClass: [UIImageView class]]) {
                        ((UIImageView *)subview).image = [UIImage imageNamed: @"yourimage.png"];
                    }
                }
            }
        }
    }   
}
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 一、简介 <<UITableView(或简单地说,表视图)的一个实例是用于显示和编辑分层列出的信息的一种手段 <<...
    无邪8阅读 13,690评论 3 3
  • 一、简介 官方给出了比较全面的介绍,要点摘录如下: table view的作用:导航、展示索引列表、展示详情信息、...
    quantiza阅读 4,130评论 0 1
  • 前几天在微博上看到一则消息:目前可以在技术上初步模拟出人去世后变成一棵大树的过程。可以先选择一棵属于你的树,人死后...
    青玫竹语阅读 3,538评论 0 1
  • 走进机场的候机厅,在宽敞的走道上闲散地漫步,经过每一个登机口,都可以感受到等待的人群在春日午后困乏的疲倦。突然,一...
    Olivewj阅读 3,177评论 0 0
  • dfdfdsfdffsdf
    杨疯阅读 2,806评论 0 1

友情链接更多精彩内容