1
我想在重新加载数据之前删除表格视图中的所有行,但似乎无法使其工作。在重新加载之前删除表格行
在我的viewcontroller中,我从这个AFNetworking请求中获得我的数组。
- (void)viewDidLoad
[[LocationApiClient sharedInstance] getPath:@"locations.json"
parameters:nil
success:
^(AFHTTPRequestOperation *operation, id response) {
NSLog(@"Response: %@", response);
NSMutableArray *location_results = [NSMutableArray array];
for (id locationDictionary in response) {
Location *location = [[Location alloc] initWithDictionary:locationDictionary];
[location_results addObject:location];
}
self.location_results = location_results;
[self.tableView reloadData];
}
failure:
^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error fetching locations!");
NSLog(@"%@", error);
}];
}
而且我想删除的数据,然后通过这个按钮
- (IBAction)locationPressed:(id)sender {
[[Location sharedSingleton].locationManager startUpdatingLocation];
[self viewDidLoad];
NSMutableArray *location_results = [NSMutableArray array];
[location_results removeAllObjects];
[self.tableView reloadData];
}
重新加载它,但它不删除行。我看到重载发生在已经存在的行的顶部。有什么建议么?
Thanks @Gabriele,这是非常有帮助的。我应该在哪里调用removeAllObjects?在重新加载之前,实施建议仍然不会清除表格视图。 – jacobt 2013-04-10 04:18:09
@jacobt这取决于你想达到什么目的?你想要消失的图形效果吗?或者干脆重新加载整个表? – 2013-04-10 04:19:17
我希望按下按钮后消失的图形效果,然后用新数据重新加载表格单元格。可能吗?谢谢你的帮助! – jacobt 2013-04-10 04:25:40