Whoami
Whoami

Reputation: 14418

custom UITableViewCell height width provies wrong value.

I have designed UITableViewCell in .xib, and its height and width is :

Retrieving from the Xcode ->Show the size inspector.

Width : 358   Height : 562 

TableView Delegate:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    return 800;
 }

What I am trying?

In the following method, i m trying to find width and height of the cell, so that i can draw a vertical line in the cell.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:   (NSIndexPath *)indexPath 
{
  /* FINDING THE WIDTH AND HEIGHT */
   my Custom Cell instance say : cell

   cell.contentView.bounds.size.width   Give  me the value -> 320,
   cell.contentView.bounds.size.height  Gives me the value -> 44,
}

Question?..

How can i get the correct height/width of the custom cell?

Kindly let know if my understanding is wrong?

Upvotes: 1

Views: 691

Answers (1)

Tricertops
Tricertops

Reputation: 8512

You need to override -tableView:willDisplayCell:forRowAtIndexPath:. In this method the correct dimensions are already set up by table view.

Upvotes: 1

Related Questions