user3218052
user3218052

Reputation: 11

how to make custom tableview in which if row is one then tableview also appear as one row table

In my application i am using three table view and data is coming from web service.and in my first table there is only one data come but it shows whole table. After click on that second table appear in which 4 data come and shows whole table.

So i want that if array count is whatever as per that my table reduce/gain size it self.

Here is my Code:

- (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;
}

Upvotes: 0

Views: 46

Answers (1)

user2435304
user2435304

Reputation:

You can change the height of the tableview when ever you know the count for like set tableView Height to countOFTheArrayForTableView * heightOfTheTableViewCell( 44 in normal UITableView). Let me know if you need the code for this.

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

Upvotes: 1

Related Questions