1

I found out that the cell bounds is always (320, 44) when I dequeue reusable cell in the cellForRowAtIndexPath method.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                                reuseIdentifier:kCellIdentifier_ActCalendarCell];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
    cell.textLabel.text = @"test";
    NSLog(@"%f,%f", cell.bounds.size.width, cell.bounds.size.height);
    return cell;
}

Is that designed? When and where can i get the real bounds of cell?

xi.lin
  • 3,326
  • 2
  • 31
  • 57
  • What are you trying to do with the bounds? – chedabob May 18 '15 at 10:20
  • @chedabob I'm trying to add top round rect for cell, like [this](http://stackoverflow.com/questions/22410254/round-top-corners-of-a-uiview-and-add-border) – xi.lin May 18 '15 at 10:47

1 Answers1

0
NSIndexpath  *indexPath=self.tableView indexPathForSelectedRow
CustomCell *cell = (CustomCell*)[self cellForRowAtIndexPath:indexPath];
CGRect cellFrameInTableView = cell.frame;

//Use this to get actual coordinates

CGRect cellFrameInWindow = [self convertRect:cellFrameInTableView toView:[UIApplication sharedApplication].keyWindow];
Mukesh
  • 3,680
  • 1
  • 15
  • 32