1

我在编辑表格视图时遇到问题:

我将编辑模式下的减号位置更改为单元格的右侧。
问题是按钮从左侧滑动,这使它看起来很奇怪。
有没有办法改变这个动画?

此外,撤消删除选项时有一个动画(显示红色删除按钮时单击减号),知道为什么吗?

这是显示该问题的视频:

---编辑---
这就是我改变位置的方式:

- (void)layoutSubviews {
[super layoutSubviews];


//Indent to the left instead of right
self.contentView.frame = CGRectMake(0,
                                    self.contentView.frame.origin.y,
                                    self.contentView.frame.size.width,
                                    self.contentView.frame.size.height);

if ((self.editing
    && ((state & UITableViewCellStateShowingEditControlMask)
        && !(state & UITableViewCellStateShowingDeleteConfirmationMask))) ||
    ((state & UITableViewCellStateShowingEditControlMask)
     && (state & UITableViewCellStateShowingDeleteConfirmationMask)))
{
    float indentPoints = self.indentationLevel * self.indentationWidth;

    self.contentView.frame = CGRectMake(indentPoints - 35,
                                        self.contentView.frame.origin.y,
                                        self.contentView.frame.size.width - indentPoints,
                                        self.contentView.frame.size.height);
}

//Change editAccessoryView location
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.0f];
//If can't use private classes (UITableViewCellDeleteConfirmationControl..), use [self.subviews objectAtIndex:0];

for (UIView *subview in self.subviews) {


    if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {
        CGRect newFrame = subview.frame;
        newFrame.origin.x = 10;
        subview.frame = newFrame;
    }
    else if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellEditControl"]) {
        CGRect newFrame = subview.frame;
        newFrame.origin.x = 280;
        subview.frame = newFrame;

    }
    else if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellReorderControl"]) {
        CGRect newFrame = subview.frame;
        newFrame.origin.x = 200;
        subview.frame = newFrame;
    }
}
[UIView commitAnimations];

}

- (void)willTransitionToState:(UITableViewCellStateMask)aState {
[super willTransitionToState:aState];
self.state = aState;
}

---edit2---
我确定导致减号跳转问题的部分是
//Change editAccessoryView 位置。
没有它就没有跳跃,但减号按钮又回到了单元格的左侧。
有什么办法吗?

4

1 回答 1

0

只是一个猜测,但您是否尝试过颠倒视图?您也许可以使用UIView transform.

(代码来自网络,不知道可靠性如何)

CGAffineTransform rotateTransform;
rotateTransform = CGAffineTransformRotate(CGAffineTransformIdentity, M_PI);
myView.transform = rotateTransform;
于 2013-03-06T20:06:25.323 回答