0

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....

The iOSDev
  • 5,237
  • 7
  • 41
  • 78
JKMania
  • 239
  • 1
  • 6
  • 17

2 Answers2

1

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

Saad
  • 8,857
  • 2
  • 41
  • 51
  • Or he means that the reuse ability of the table doesnt load initial offscreen items. – Wesley May 07 '12 at 10:59
  • 1
    i thnk a question must have it's code included in question so that one can easily understand and answer it – Saad May 07 '12 at 11:01
  • @The Saad: I tried for [arr count] in numberOfRowsInSection but still it show me 9 rows on viewload but when i scroll the table view then all rows get displayed. I want to call all this 15 row in CellForRowAtIndexpath method to add each row cell.textView in other array. – JKMania May 07 '12 at 11:07
  • @Wesso you are right! I want the reuse ability of the table doesnt load initial offscreen items. please help me – JKMania May 07 '12 at 11:08
  • @SanjayDarshil post your code and mention in that what you want – Saad May 07 '12 at 11:10
  • Following is the code which i implemented - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [arrFields count]; } and // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // In this method I get only first 9 cell.textview to add in array for each item in arrFields.} – JKMania May 07 '12 at 11:13
  • are you sure you have 15 array fields? and post your cellForRow.. as it is here – Saad May 07 '12 at 11:17
  • - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *CellIdentifier = [NSString stringWithString:strColname]; MyTableViewCell *cell = (MyTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell =[[[MyTableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier:0]autorelease]; } cell.label.text = [arrFields objectAtIndex:indexpath.row]; // In this array i want to add this cell.textview [ArrayCellText addObject:cell.textView]; } – JKMania May 07 '12 at 11:29
  • Why would you want to preload every cell. You should never use a cell as your personal database. – Wesley May 07 '12 at 11:32
  • http://www.icodeblog.com/2009/05/24/custom-uitableviewcell-using-interface-builder/ see this tutorial – Saad May 07 '12 at 11:55
  • http://stackoverflow.com/questions/4238760/how-to-make-a-uitableviewcell-with-a-uitextview-inside-that-dynamically-adjust see this thread – Saad May 07 '12 at 12:07
1

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
}
vishiphone
  • 750
  • 7
  • 14