表数据不会动态重新加载

时间:2011-11-12 11:11:14

标签: iphone uitableview uinavigationcontroller

我正在开发一个基于导航的应用程序,其中表格数据通过另一个页面动态输入。但是当导航回表格时,它不会显示数据。它仅在现有应用程序之后显示数据并重新启动它。任何帮助将不胜感激。这是我的代码。

- (void)viewWillAppear:(BOOL)animated {
 [super viewWillAppear:animated];
listOfNotes=[[NSMutableArray alloc]init];

NSString *docsDir;
NSArray *dirPaths;
dirPaths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir=[dirPaths objectAtIndex:0];

databasePath=[[NSString alloc]initWithString:[docsDir stringByAppendingPathComponent:@"myApplicationDatabase.sqlite"]];
const char *dbPath=[databasePath UTF8String];
if (sqlite3_open(dbPath, &contactDB)==SQLITE_OK) {
    const char *sql="select notes from message";
    sqlite3_stmt *statement;
    if (sqlite3_prepare_v2(contactDB, sql, -1, &statement, NULL)==SQLITE_OK){

        while (sqlite3_step(statement)==SQLITE_ROW) {
            NSString *list=[NSString stringWithUTF8String:(char*)sqlite3_column_text(statement, 0)];
            [listOfNotes addObject:list];
        }
        sqlite3_finalize(statement);

    }
    sqlite3_close(contactDB);
}
tableData=[[NSMutableArray alloc]init];
[tableData addObjectsFromArray:listOfNotes];

   }

1 个答案:

答案 0 :(得分:2)

尝试通过

重新加载表格
[table reloadData];