2013-03-06 15 views
1

我遇到编辑表视图的问题:更改UITableViewCell的减号动画

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

此外,还有一个动画时撤消删除选项(当显示红色删除按钮时单击减号),任何想法为什么?

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位置。
没有它,没有跳跃,但减号按钮回到单元格的左侧。
任何方式呢?

+0

你是如何改变位置? – 2013-03-06 20:04:13

+0

@MarcusAdams看到我编辑的答案。 – oridahan 2013-03-06 20:08:17

+0

当你最终国际化表格视图单元格时,你所做的任何事情都可能会被破坏。也许你可以忍受默认行为? – 2013-03-06 22:04:05

回答

0

只是一个猜测,但你有没有尝试将视图颠倒?您可能可以使用UIViewtransform

(代码来自互联网,不知道它是多么可靠)

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

可以详细说明 – oridahan 2013-03-06 20:10:42

+0

谢谢,这是一个不错的主意,但整个单元格倒过来。 – oridahan 2013-03-06 20:29:13

+0

你应该将它应用到删除控制视图,而不是整个单元格 – 2013-03-06 20:35:18