0

So I have a view controller which adopts UITableViewDelegate:

@interface MyViewController:UIViewController<UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITabelView *myTableView;
@end

In the implementation file MyViewController.m, I override

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

My question is, how does the height of tabel view row get returned to myTableView and further sets the height of each individual row?

Edited: Just to be clear, I tried to implement this mechanism in my own custom view class where specific information is asked for to lay out the view. I have no problem using UITabelView itself. :)

nyus2006
  • 411
  • 6
  • 12

1 Answers1

0

You question isn't very clear but the code inside the UITableView which asks the delegate for the cell height would simply be something like this.

CGFloat thisCellHeight = [self.delegate tableView:self heightForRowAtIndexPath:thisCellIndexPath];

It send a message back to the delegate and asks...

trapper
  • 11,716
  • 7
  • 38
  • 82
  • @trapper, so when the line "return xxx;" inside -(CGFloat)tableView: heightForRowAtIndexPath: is executed, another delegate message is sent out back to the table view? – nyus2006 May 25 '12 at 15:41
  • Not exactly. The message is initiated by the UITableView and sent to the delegate, the delegates return value (the CGFloat) is the only thing returned back to the UITableView – trapper May 25 '12 at 15:43
  • If you are interested in the 'under the hood' implementation of how messaging actually works then there is a lot to read, but this is probably more detail than you need. Check this: http://stackoverflow.com/questions/982116/objective-c-message-dispatch-mechanism – trapper May 25 '12 at 15:47