gpt4 book ai didi

objective-c - 分段 UITableView 刷新

转载 作者:行者123 更新时间:2023-11-29 04:52:23 28 4
gpt4 key购买 nike

在我的应用程序中,弹出窗口中的 UITableView 会在新数据时重新加载。如果表格未分区,则使用此代码一切都可以完美运行:

通知,启动重新加载:

- (void)recieveNotification:(NSNotification*) notification {
if ([[notification name] isEqualToString:@"NewDataArrived"]) {
[self viewWillAppear:YES];
}

重新加载的方法:

- (void)viewWillAppear:(BOOL)animated
{
//Formation of the new content of table

[self.tableView reloadData];
[super viewWillAppear:animated];
}

但是如果我按部分对内容进行排序,一切都会变得困惑。查看不重新加载,新数据只是添加到表格末尾的最后一部分。

各部分的标题:

- (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 .

我已经花了很多时间来解决这个问题,并且非常感谢您的任何建议。

最佳答案

喜欢这个 friend !!!

.h

   -(void)myOwnMethod:(id)sender;

.m

-(void)myOwnMethod:(id)sender{

[self.tableView reloadData];


}
- (void)recieveNotification:(NSNotification*) notification {
if ([[notification name] isEqualToString:@"NewDataArrived"]) {
// [self viewWillAppear:YES];

[self myOwnMethod];

}
}

关于objective-c - 分段 UITableView 刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8601540/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com