UITableView 编辑不起作用
我有一个 UITableView 位于弹出窗口中的 NavigationController 中。因此,我放置了一个编辑/完成的 UIToolBarItem,它工作正常,您可以看到删除附件图标出现。但是,当我重新排列项目时,编辑/完成按钮停止工作...
我进行了调试,它仍然被调用,但它似乎没有更新,并且有点阻止其他按钮的任何进一步更新。这可能是模拟器的问题吗?
感谢您提前的帮助!
编辑:添加代码
addButton = [[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UIBarButtonItemStyleBordered target:self action:@selector(editTable:)];
稍后介绍方法:
- (IBAction) editTable: (id) sender
{
if ([[addButton title] isEqualToString:EDIT_STRING]) {
[addButton setTitle:DONE_STRING]; //enabling edit mode
[super setEditing:YES animated:YES];
[[self tableView] setEditing:YES animated:YES];
}
else {
[addButton setTitle:EDIT_STRING]; //done with editing
[[self tableView] setEditing:NO animated:YES];
[super setEditing:NO animated:YES];
[[self tableView] setNeedsDisplay];
[[self tableView] reloadData];
}
}
随着 addButton 文本的更改,第二部分肯定会被调用。但是,一旦我进行编辑(例如重新排列行),它就会停止工作
I have a UITableView which lies in a NavigationController that is in a popover. So, I put an edit/done UIToolBarItem which works fine and you can see the delete accessory icon showing up. However, when I rearrange the items, the edit/done button stops working...
I debugged and it still gets called but it doesn't seem to update and is sort of preventing any further updates from other buttons. Is this possibly a problem with the simulator?
Thanks for the help in advance!
Edit: Adding code
addButton = [[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UIBarButtonItemStyleBordered target:self action:@selector(editTable:)];
And later on the method:
- (IBAction) editTable: (id) sender
{
if ([[addButton title] isEqualToString:EDIT_STRING]) {
[addButton setTitle:DONE_STRING]; //enabling edit mode
[super setEditing:YES animated:YES];
[[self tableView] setEditing:YES animated:YES];
}
else {
[addButton setTitle:EDIT_STRING]; //done with editing
[[self tableView] setEditing:NO animated:YES];
[super setEditing:NO animated:YES];
[[self tableView] setNeedsDisplay];
[[self tableView] reloadData];
}
}
The second part is definitely called as the addButton text is changing. However, it stops working once I make an edit (such as re-arranging a row)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,
我似乎已经调用了 [tableView beginUpdates] 而从未调用过 endUpdates,这导致所有更新都未注册。如果其他人这样做的话...
Alright,
I seemed to have called [tableView beginUpdates] and never called endUpdates, which was causing all updates to not be registered. If anyone else does that...