我已经阅读了很多这样的帖子,但我做的一切似乎都没有用。我只是尝试使用委托方法删除UITableView中的所有行:
deleteRowsAtIndexPaths
以下是我正在使用的代码:
- (void) clearNonATITable {
NSMutableArray* arrIndexPaths = [NSMutableArray array];
if (self.arrNonATIResults.count > 0) {
[self.accountTable beginUpdates];
for(int i=0; i<self.arrNonATIResults.count; i++) {
NSIndexPath* indexPath = [NSIndexPath indexPathForRow:i inSection:0];
[self.accountTable deleteRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationFade];
}
[self.accountTable endUpdates];
[self.accountTable reloadData];
[self.arrNonATIResults removeAllObjects];
}
}
以下是我用来填充数据源的代码:
- (void) updateNonATITable {
[self.arrNonATIResults removeAllObjects];
//setting up some test data - DELETE WHEN SERVICES ARE UP
NSDictionary* dictRow1 = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithBool:YES], @"Is Target",
@"Local Pharmaceutical", @"Company Name",
@"71234567", @"Company ID",
@"123 Anystreet", @"Address",
@"Small Town", @"City",
@"Small Cell", @"Cell 5",
@"Booyeah!", @"Comments",
nil];
NSDictionary* dictRow2 = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithBool:NO], @"Is Target",
@"Big Pharmaceutical", @"Company Name",
@"78903456", @"Company ID",
@"123 Main Street", @"Address",
@"Big City", @"City",
@"Small Cell", @"Cell 5",
@"Brady Rules!", @"Comments",
nil];
self.arrNonATIResults = (NSMutableArray*)[NSArray arrayWithObjects:dictRow1, dictRow2, nil];
//reload table
[self.accountTable reloadData];
[self.accountTable scrollRectToVisible:CGRectMake(0, 0, self.accountTable.frame.size.width, 38.0f) animated:YES];
}
断言错误是:
Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-3318.93/UITableView.m:1582
答案 0 :(得分:0)
问题是在删除表行并重新加载表后删除数组中的数据。
可靠的方法是首先删除数组中的数据,然后在- (void) clearNonATITable {
NSInteger count = (NSInteger)self.arrNonATIResults.count;
if (count > 0) {
NSMutableArray *arrIndexPaths = [NSMutableArray array];
[self.accountTable beginUpdates];
[self.arrNonATIResults removeAllObjects];
for (NSInteger i = 0; i < count; i++) {
[arrIndexPaths addObject:[NSIndexPath indexPathForRow:i inSection:0]];
}
[self.accountTable deleteRowsAtIndexPaths:arrIndexPaths withRowAnimation:UITableViewRowAnimationFade];
[self.accountTable endUpdates];
// The line to reload the table might be not necessary as the animation updates the table
// [self.accountTable reloadData];
}
}
块中删除表行
import tkinter as tk
from tkinter import messagebox
# post a message
def post_message():
messagebox.showinfo("Sample Messgebox", "close this and look at button")
root = tk.Tk()
b = tk.Button(root, text="Press Me", command=post_message)
b.pack()
root.mainloop()