call the properties of a Tableviewcell in a Viewcontroller

Asked

Viewed 58 times

1

I’m trying to create a tableview with Cell dynamic according to the text inside it, and I’m trying to add the height of the label to the size of Cell but when I call the label in Viewconrtoller it’s empty and when I call in Tableviewcell it gives me the right size, how to pass (label.frame.size.height) from Tableviewcell to viewcontroller without losing its value.

  • Try this. <pre> -(Cgfloat)tableView:(Uitableview *)tableView heightForRowAtIndexPath: (Nsindexpath *)indexPath </pre>

  • I’m already using this method but I can’t pass the value of the label that is in my Tableviewcell to the viewcontroller

  • how you calculate cell phone size?

  • CGSize maximumLabelSize = CGSizeMake(296, FLT_MAX);&#xA; &#xA;CGSize expectedLabelSize = [self.descriptin.text sizeWithFont:self.label.font constrainedToSize:maximumLabelSize lineBreakMode:self.label.lineBreakMode];&#xA; &#xA; CGRect newFrame = self.label.frame;&#xA; newFrame.size.height = expectedLabelSize.height;&#xA; self.label.frame = newFrame;&#xA;

  • Dynamic Table View Cell Height and Auto Layout - http://www.raywenderlich.com/73602/dynamic-table-view-cell-height-auto-layout

  • This does not provide an answer to the question. To criticize or ask for clarification from an author, leave a comment below its publication - you can always comment on your own publications and when you have reputation points enough you will be able comment on any publication.

  • Publish the code you made so we can help you.

Show 2 more comments

1 answer

0


you can try this on cellForRowAtIndexPath:

    cell.Label-em-questao.tag = 789;
    [self sendCELL:cell];

then you recover the data in:

- (void)sendCELL:(UITableViewCell *)sender {
    CGRect tag = [(UILabel*)[(UITableViewCell *)sender.superview viewWithTag:789]frame];
    int width = tag.size.width;
    NSLog(@"%d", width);
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.