使用CGRectOffset移动单元格 - 我做错了什么?

时间:2013-06-05 01:10:52

标签: ios objective-c uitableview uigesturerecognizer cgrect

我偶然发现this奇妙的库来实现表格视图单元格滑动,但它提供的内容和我想要的内容之间存在一些细微的差别,所以我将继续实施。

开发人员移动表格视图单元格的方式很有创意,我想,他使用CGRectOffset()向单元格的两侧添加几乎填充,因为它移动到看起来像是在移动。

我想为我做类似的事情,因为这似乎是实现这一目标的最简单方法。但是,当我执行以下操作时,单元格没有任何反应:

(仅举例):

    CGFloat offset = 11;
    self.contentView.frame = CGRectOffset(self.contentView.bounds, offset, 0);

我在那里设置了一个断点,所以当我平移到单元格时它确实被调用(它在手势识别器方法中)。然而,在它被调用后,该单元的位置看起来相同。

我在开头就有这个,类似于他设置视图的方式:

- (void)awakeFromNib {
    [super awakeFromNib];

    self.contentView.backgroundColor = [UIColor whiteColor];

    UIView *backgroundView = [[UIView alloc] initWithFrame:self.contentView.frame];
    backgroundView.backgroundColor = [UIColor whiteColor];
    self.backgroundView = backgroundView;

    UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pannedCell:)];
    panGestureRecognizer.delegate = self;
    [self addGestureRecognizer:panGestureRecognizer];
}

所以我不确定为什么它不起作用。有没有人有任何想法?

0 个答案:

没有答案