objective-c - 分段 UITableView 刷新

标签 objective-c ios cocoa-touch uitableview

在我的应用程序中,弹出窗口中的 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/

相关文章:

php - 在 iOS 中检索 SQL 数据

objective-c - 如何将多个 NSMutableDictionaries 中的键更改为当前值的 -1?

objective-c - 在第 3 代 iPad 中放大时删除和刷新 CATiledLayer

objective-c - iCloud:获取文件的现有公共(public) URL

ios - Storyboard中的空白原型(prototype)单元格

ios - 在 Xcode 版本 4.5.2 (4G2008a) 包中找不到 OpenGL ES 性能侦探

ios - 更改 QLPreviewController 中的导航栏颜色

iOS - UITableView - 取消删除行 - 按钮动画仅适用于附件 View

ios - 核心数据 : many-to-many relationship with state

ios - UIViewController 基类——好不好