【发布时间】:2011-11-12 11:11:13
【问题描述】:
我正在开发一个基于导航的应用程序,其中表格数据通过另一个页面动态输入。但是当导航回 table 时,它不显示数据。它仅在现有应用程序并重新启动后才显示数据。任何帮助将不胜感激。这是我的代码。
- (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];
}
【问题讨论】:
标签: iphone uitableview uinavigationcontroller