向左移动重新排序控件 [英] Moving reordering control to left

查看:53
本文介绍了向左移动重新排序控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将重新排序控件移到单元格的左侧.我正在使用自定义单元格,并且我的单元格具有按钮.实际上,我可以使用以下功能将其向左移动.但是我的右键最初是默认的重新排序控件所在的位置,因此即使在应用转换后也无法访问.可访问不落后的部分.

I am trying to move the reordering control to the left of the cell. I am using custom cells and my cell has button. I am actually able to move it the left by using the following function. But my right button is originally where the default reordering control is and hence is not accessible even after applying the transform. The part which is not behind is accessible.

作为参考,我使用了以下这些链接 http://b2cloud.com. au/如何指导/从任何接触点重新排列一个uitableviewcell

As reference I have used these following links http://b2cloud.com.au/how-to-guides/reordering-a-uitableviewcell-from-any-touch-point

>如何在左侧对UITableViewCell进行重新排序控制侧面?

#pragma mark - 
#pragma mark rows reordering

- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    for(UIView* view in cell.subviews)
    {
        if([[[view class] description] isEqualToString:@"UITableViewCellReorderControl"])
        {
            UIView* resizedGripView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetMaxX(view.frame), 48)];
            [resizedGripView setBackgroundColor:[UIColor whiteColor]];
            [resizedGripView addSubview:view];
            [cell addSubview:resizedGripView];

            //  Original transform

           const CGAffineTransform transform = CGAffineTransformMakeTranslation(40 - cell.frame.size.width, 1);


            [resizedGripView setTransform:transform];
            /*for(UIImageView* cellGrip in view.subviews)
            {
                if([cellGrip isKindOfClass:[UIImageView class]])
                    [cellGrip setImage:nil];
            }*/
        }
    }
}

请查看此图片 http://i.stack.imgur.com/xBDLG.png

在重新排序控件的原始位置上无法访问单元格中的编辑按钮.休息很好.

The edit button in the cell is not accessible on the original location of reorder control. Rest is working fine.

推荐答案

尝试一下,希望对您有帮助

Try this, I hope it helps

- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell
 forRowAtIndexPath:(NSIndexPath *)indexPath
{
    for(UIView* view in cell.subviews)
    {
        if([[[view class] description] isEqualToString:@"UITableViewCellReorderControl"])
        {

            UIView* resizedGripView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetMaxX(view.frame), CGRectGetMaxY(view.frame))];
            [resizedGripView addSubview:view];
            [cell addSubview:resizedGripView];

            //  Original transform
            const CGAffineTransform transform = CGAffineTransformMakeTranslation(view.frame.size.width - cell.frame.size.width, 1);
            //  Move custom view so the grip's top left aligns with the cell's top left

            [resizedGripView setTransform:transform];
        }
    }
}

这篇关于向左移动重新排序控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆