我的UItableView中的顶部单元格不会出现

时间:2013-04-20 16:36:44

标签: ios xcode ipad uitableview

这是我的问题:

我有不同部分的uitableview,每个部分都有很多行。

问题在于,当我在iPad模拟器中运行应用程序时,UITableView中第0行的前五行不会出现,除非我向上滚动查看它们然后它们在停止滚动后又回来了?

请帮助。 提前谢谢和快乐的编码。

以下是数据源方法的实现:1。部分数量:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
        // Return the number of sections.
        NSMutableArray *catarr = [[NSMutableArray alloc] init];
        catarr= [d Category];
        NSInteger length ;

        length = [catarr count];

        return length;
    }

2.行数:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.

    NSMutableArray *catarr = [[NSMutableArray alloc] init];
    catarr = [d Category];
    NSInteger length ;
    length = [catarr count];
    NSInteger count ;
    NSMutableArray *word;

    for ( int i=0 ; i < length ; i++)
    {
        if (section == i )
        {
            NSString *str = [catarr objectAtIndex:i];
            word = [[NSMutableArray alloc] init];
            word = [d CatRowName:str];
            count = [word count];
            return count;
        }
    }

    return 0 ;
}

3。索引路径上的单元格:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString *CellIdentifer = @"Cell"; 
    UITableViewCell *cell= [ tableView dequeueReusableCellWithIdentifier:CellIdentifer];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                      reuseIdentifier:CellIdentifer]; 
    }

    cell.textLabel.font = [UIFont systemFontOfSize:17.0];
    UILabel *label ;

    label=(UILabel *)[cell viewWithTag:1];
    NSString *value = [[mainArray objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]; 
    label.text = value;
    label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;


    label=(UILabel *)[cell viewWithTag:2];
    NSString *value2 = [[mainArray2 objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
    label.text= value2;


NSString *value3 = [[mainArray3 objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
     cell.imageView.image = [UIImage imageNamed:value3];
    label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;


    return cell;

}

0 个答案:

没有答案