JKMania
JKMania

Reputation: 239

How to Handle CellForRowAtIndexpath method

I had one table view in which I had 15 row in one section. so when the table view get loaded it shows only first 9 rows, I checked it with method CellForRowAtIndexpath method but I want to get all 15 rows to be get called in this method for the viewload method. please help me on out.

thanks in advance....

Upvotes: 0

Views: 900

Answers (2)

vishiphone
vishiphone

Reputation: 750

You use these method or if you want all your cell on front of first time view then you should decrease the height of the cell using last method.And also check your array how much values he have.

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{
return 1;
}

-(NSInteger)tableView:(UITableView *)tableView  numberOfRowsInSection:(NSInteger)section 
{
return [Array count];

}
-(UITableViewCell *)tableView:(UITableView *)tableView
     cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
   static NSString *CellIdentifier = @"Cell";
   UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
   if (cell == nil) {
    cell = [[[UITableViewCell alloc]
             initWithStyle:UITableViewCellStyleSubtitle
             reuseIdentifier:CellIdentifier]
            autorelease];
 }
   cell.textLabel.text=[Array objectAtIndex:indexPath.row];


    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 20;//use this method for cell height
}

Upvotes: 1

Saad
Saad

Reputation: 8947

it depends how much rows you set from

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

if you have an array then return [arr count]; as number of rows and if you want static rows then use return 15; in this method

Upvotes: 1

Related Questions