更改UITableViewCell的减号动画

时间:2013-03-06 19:42:58

标签: ios objective-c cocoa-touch uitableview

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

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

此外,撤消删除选项时会显示动画(显示红色删除按钮时单击减号),有什么想法吗?

Here is a video显示问题:

--- ---编辑
这就是我改变立场的方式:

- (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
我发现造成负号跳跃问题的部分是      //更改editAccessoryView位置 如果没有它,则没有跳跃,但减号按钮返回到单元格的左侧 任何方式?

1 个答案:

答案 0 :(得分:0)

只是一个猜测,但你是否尝试颠倒过来?您可以使用UIView transform

(来自互联网的代码,不确定它有多可靠)

CGAffineTransform rotateTransform;
rotateTransform = CGAffineTransformRotate(CGAffineTransformIdentity, M_PI);
myView.transform = rotateTransform;