1

我试图在 UITableview 处于编辑模式时显示和隐藏子视图,同时它显示删除按钮(整个编辑和删除过程,而不仅仅是编辑),然后在它返回正常模式时使其消失。

我真的很接近按照我想要的方式获得它,但是每次您单击单元格中的“删除”按钮时,它都会使我的视图消失,当我不希望它消失时,直到用户完全退出编辑模式.

我正在尝试使用委托方法- (void)willTransitionToState:(UITableViewCellStateMask)state,但在调用时出现错误super

- (void)willTransitionToState:(UITableViewCellStateMask)state {

    [super willTransitionToState:state];

    if ((state & UITableViewCellStateShowingEditControlMask)) {
        clear.alpha = 1.0;
    }
}

该错误很常见,但我似乎找不到解决方案:

'UITableViewController' 没有可见的@interface 声明选择器'willTransitionToState:'

如果我不调用 super,我不会收到错误,但该方法也永远不会被调用。

我也尝试过使用setEditing,但是当点击删除按钮时,我希望在整个编辑/删除过程中保持可见的视图消失了,删除了单元格,但仍处于编辑模式

4

2 回答 2

1

willTransitionToState是一种方法 on UITableViewCellnot on UITableViewController

于 2012-07-10T23:57:30.120 回答
1

You need to call that method (willTransitionToState:) in your custom tableview cell. it isn't a method that is recognized in a UITableViewController class. if you call willTransitionToState: in the .m file if your custom tableview cell class, it should work. Just make sure that cell class has the ivar 'clear' defined (which you seem to have, based on the code you provided). Also check out the layoutSubviews method if you'd like to do things like prevent the cells from indenting content while editing.

于 2012-07-11T08:24:39.547 回答