如何制作自定义tableview,如果row为1,则tableview也显示为一个行表

时间:2014-04-05 05:29:41

标签: ios iphone objective-c uitableview

在我的应用程序中,我使用三个表视图,数据来自Web服务。在我的第一个表中只有一个数据,但它显示整个表。点击第二个表后出现4个数据并显示整个表。

所以我想要的是,如果数组计数是根据我的表减少/增加它自己的大小。

这是我的代码:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if(rubrixTbl==tableView) //
    {
        if (str!=nil)

//*******here str is NSString abject.
 {         
            return 1;
        }

        else

        {
            return 0;
        }

    } if (rubrixTbl2==tableView)
 {
        return [rubaricIDarr count];
//*****rebaricDarr is object of nsmutablearray********
    }

    if(rubrixTbl3==tableView)  
  {
        return [table3Array count];
    }

    return 0;
}

1 个答案:

答案 0 :(得分:1)

如果您知道了相同的set tableView Height的计数,则可以更改tableview的高度countOFTheArrayForTableView * heightOfTheTableViewCell(在普通UITableView中为44)。如果您需要此代码,请告诉我。

    tbl.frame = CGRectMake(tbl.frame.origin.x, tbl.frame.origin.y, tbl.frame.size.width, [array count]*44);