您的位置:首页 > 产品设计 > UI/UE

如何在使用moveRowAtIndexPath:方法时替换默认图片

2016-12-14 14:25 495 查看
在用- (void)tableView:(UITableView *)tableView
moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath方法实现重排时,有一个三条线的默认图片,下面的方法可以实线替换默认图片

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell
forRowAtIndexPath:(NSIndexPath *)indexPath{

    for (UIView *viewin cell.subviews)
{

        if ([[[viewclass]
description]isEqualToString:@"UITableViewCellReorderControl"]) {

            for (UIView *vin view.subviews)
{

                if ([visKindOfClass:[UIImageViewclass]])
{

                    [v removeFromSuperview];

                }

            }

            UIImageView *imageView = [[UIImageViewalloc]initWithFrame:CGRectMake(5,5,
35,35)];

            imageView.image = [UIImageimageNamed:@"change.png"];

            [view addSubview:imageView];

        }

    }

    

}

或者在自定义的cell的m文件中添加如下方法

- (void)layoutSubviews{

    [super layoutSubviews];

    for (UIView *view
in self.subviews) {

        if ([[[view class] description] isEqualToString:@"UITableViewCellReorderControl"]) {

            for (UIView *v
in view.subviews) {

                if ([v isKindOfClass:[UIImageView class]]) {

                    [v removeFromSuperview];

                }

            }

            UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(5,
5, 35,
35)];

            imageView.image = [UIImage imageNamed:@"change.png"];

            [view addSubview:imageView];

        }

    }
<
b789
p style="margin-top:0px;margin-bottom:0px;line-height:normal;font-family:Menlo;">
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息