多个UITableViews,一个视图,两个填充,一个空白。有什么问题?

时间:2014-01-04 02:42:17

标签: uitableview ios7 nsmutablearray nsarray

我在一个视图中有3个tableView,由于某种原因,其中有两个显示数据,但有一个不是,我的问题是什么?!!

enter image description here

enter image description here

我猜测问题出在cellForRowAtIndexPath声明中。附上它。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier=@"Cell";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    if (tableView==_titleTV) {
        NSDictionary *dictionaryTwo = [_titleArray objectAtIndex:indexPath.section];
        NSArray *arrayTwo = [dictionaryTwo objectForKey:@"data"];
        NSString *cellValueTwo = [arrayTwo objectAtIndex:indexPath.row];
        cell.textLabel.text = cellValueTwo;
    }
    if (tableView==_cuisineTV) {
        NSDictionary *dictionary = [_cuisineArray objectAtIndex:indexPath.section];
        NSArray *array = [dictionary objectForKey:@"data"];
        NSString *cellValue = [array objectAtIndex:indexPath.row];
        cell.textLabel.text = cellValue;

    }
    else {
        int storyIndex = [indexPath indexAtPosition: [indexPath length]-1];
        cell.textLabel.text=[_favouritesArray objectAtIndex: storyIndex];
    }
    return cell;

}

问题是什么?

谢谢, SebOH。

1 个答案:

答案 0 :(得分:1)

尝试打印cellValueTwo的值以确保其不是空白字符串:

NSLog(@"cellValueTwo value: %@",cellValueTwo);

您是否检查过以确保为_titleTV创建的单元格数与您对- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section的期望是否正确?