[英]Sectioned UITableView refreshing
In my application is the UITableView in popover, which reloading when new data. 在我的应用程序中是弹出窗口中的UITableView,当有新数据时会重新加载。 If table not sectioned, all works perfect with this code: 如果未对表进行分段,则此代码可完美使用:
Notification, which initiate reloading: 通知,将启动重新加载:
- (void)recieveNotification:(NSNotification*) notification {
if ([[notification name] isEqualToString:@"NewDataArrived"]) {
[self viewWillAppear:YES];
}
Method that reloads: 重新加载的方法:
- (void)viewWillAppear:(BOOL)animated
{
//Formation of the new content of table
[self.tableView reloadData];
[super viewWillAppear:animated];
}
But if I sort content by sections, everything goes to chaos. 但是,如果我按部分对内容进行排序,那么一切都会变得混乱。 View not reloading and new data just adding to the end of table, into last section. 查看未重新加载,新数据仅添加到表的末尾。
Headers for sections: 各节的标题:
- (NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if (section == 0) {
return @"Cities";
} else
if (section == 1) {
return @"Hotels";
} else
if (section == 2) {
return @"Airports";
} else
return @"Landmarks";
}
Here is screenshot http://dl.dropbox.com/u/8288064/img/chaos.png . 这是http://dl.dropbox.com/u/8288064/img/chaos.png的屏幕截图 。
I've spent a lot of time on this trouble and will be grateful for any advice. 我花了很多时间解决这个麻烦,对于任何建议,我们将不胜感激。
Do like this buddy!!!! 喜欢这个哥们!!!
.h 。H
-(void)myOwnMethod:(id)sender;
.m .m
-(void)myOwnMethod:(id)sender{
[self.tableView reloadData];
}
- (void)recieveNotification:(NSNotification*) notification {
if ([[notification name] isEqualToString:@"NewDataArrived"]) {
// [self viewWillAppear:YES];
[self myOwnMethod];
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.