我有一个部分解决方案,用于将删除按钮与UITableViewCell
的右侧对齐,它成功地将按钮置于右侧,但是当我点击按钮时它没有响应。我必须点击UITableViewCell
左侧(原始删除按钮位置)才会给出回复。
- (void)willTransitionToState:(UITableViewCellStateMask)state {
[super willTransitionToState:state];
if (state == UITableViewCellStateShowingEditControlMask) {
for (UIView *subview in self.subviews) {
if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellEditControl"]) {
subview.hidden = YES;
subview.alpha = 0.0;
}
}
}
}
- (void)didTransitionToState:(UITableViewCellStateMask)state {
[super didTransitionToState:state];
if (state == UITableViewCellStateShowingEditControlMask || state == UITableViewCellStateDefaultMask) {
for (UIView *subview in self.subviews) {
if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellEditControl"]) {
UIView *deleteButtonView = (UIView *)[subview.subviews objectAtIndex:0];
CGRect f = deleteButtonView.frame;
f.origin.x += 220;
deleteButtonView.frame = f;
subview.hidden = NO;
[UIView beginAnimations:@"anim" context:nil];
subview.alpha = 1.0;
[UIView commitAnimations];
}
}
}
}
希望对这种奇怪的行为提出一些想法。