在我的 firstViewcontroller 中,我构建了一个 tableview。它的数据来自数据库。在 secondviewcontroller 中,我在数据库中插入数据,并从 firsviewcontroller 调用函数来构建字典数据,就像在 firstviewcontroller 中提取数据一样。所有数据都是从数据库中恢复,但无法重新加载 tableview。我无法访问 cellForRowAtIndexPath 甚至 numberofrowsinsection>0
这就是我所做的:
Secondviewcontroller:
//I insert data in database and I instanciate class where my tableview is and call refresh method
first = [[FirstviewController alloc]initWithNibName:@"FirstviewController" bundle:nil];
[first refreshList];
//in Firstviewcontroller
-(void)refreshList{
self.tableview= [[[UITableView alloc] initWithFrame:self.view.bounds] autorelease];
tableview.dataSource = self;
tableview.delegate = self;
NSMutableArray *array = [[NSMutableArray alloc] init];
//I recover my data from data base
IPADAGRIONEActivityList *arrayActivities = [IPADAGRIONEActivity findAll];
if ([arrayActivities length] > 0)
{
for (IPADAGRIONEActivity * oneRec in arrayActivities)
{
[array addObject:oneRec];
}
}
//activities is NSMutablearray that contains all my data
self.activities = array;
//I build dictionnary
[self buildObjectsDictionnary:activities
NSLog(@"self.act%@",self.tableview);
[array release];
[self.tableview reloadData];
}
//numberofrowsinSection:
NSLog(@"rows%d",[[objects objectForKey:[objectsIndex objectAtIndex:section]] count]);
return [[objects objectForKey:[objectsIndex objectAtIndex:section]] ;
//numberOfSection:
NSLog(@"nbre of section%d",[objectsIndex count]);
return [objectsIndex count];}
//CellforRowatInddexPath: It dosen't access to this method
if (cell== nil) {
cell = [[MHCActivityListCell alloc]init];
}
IPADAGRIONEActivity *activite ;
cell.activityCategory.text = [NSString stringWithFormat:@"%@", [activite EMAIL]];
}
}