我有一个主视图,其中有一个容器视图,其中包含一个表格视图。当我将我的数据数组传递给容器视图时,要更新什么表视图,但什么也没发生。即使容器获取数组数据,表格视图似乎也没有显示单元格。
对此有任何想法!太感谢了。一切似乎都有效,但只是不显示表格数据
// parent view success call this method to pass the the array to this container view.
- (void)listMetricsToTable:(NSMutableArray*)obj{
self.myTableView.dataSource = self;
self.myTableView.delegate = self;
allMetrics = obj;
NSLog(@"pass data : %@", allMetrics);
NSLog(@"count : %i",allMetrics.count);
[self.myTableView reloadData];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
// Return the number of rows in the section.
// Usually the number of items in your array (the one that holds your list)
NSLog(@"numberOfRowsInSection returning %d", [items count]);
return [items count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//Where we configure the cell in each row
NSLog(@"call");
static NSString *CellIdentifier = @"Cell";
CustomCell *cell =[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell... setting the text of our cell's label
//NSDictionary *show = [allMetrics objectAtIndex:indexPath.row];
//cell.metricsLabel.text = [show objectForKey:@"number"];
//cell.metricsNameLabel.text = [show objectForKey:@"name"];
cell.metricsNameLabel.text = [items objectAtIndex:indexPath.row];
return cell;
}