到目前为止,我可以使用此方法编辑我的表格视图:
- (void)setEditing:(BOOL)editing animated:(BOOL)animate
{
[super setEditing:editing animated:animate];
if(self.isEditing)
{
NSLog(@"editMode on");
[leftButton setTitle:@"Edit"];
[super setEditing:NO animated:YES];
}
else
{
NSLog(@"Done leave editmode");
[leftButton setTitle:@"Done"];
[super setEditing:YES animated:YES];
}
}
我可以进入编辑模式并编辑我的表格视图,但是当我再次点击该按钮时,它不会结束"编辑"模式。我已经尝试解决这个问题一段时间了,我迷路了。感谢所有的帮助,提前谢谢。
答案 0 :(得分:1)
这没有多大意义。你正在调用你的超类的setEditing:animated:每次执行多次,有时使用不同的参数。你应该做的是让超类使用与子类相同的编辑状态执行方法,并拉出要设置为按钮按下事件的状态的逻辑。像这样:
- (void)setEditing:(BOOL)editing
animated:(BOOL)animate
{
[super setEditing:editing
animated:animate];
if(self.isEditing) {
NSLog(@"editMode on");
[leftButton setTitle:@"Edit"];
} else {
NSLog(@"Done leave editmode");
[leftButton setTitle:@"Done"];
}
}
- (IBAction)buttonTapped:(UIButton *)sender
{
[self setEditing:!self.isEditing
animated:YES];
}