Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should be able to control the size of the subviews if you programmatically create them and add them to your tableview cell (i.e.,so that they are not set in storyboard, and thus are not subjected to explicit auto-contraints). </p> <p>In my implementation, I created a customCell subclass. In the .h:</p> <pre><code>@property (strong, nonatomic) UILabel *customLabel; </code></pre> <p>Then in the .m:</p> <pre><code>- (id)initWithCoder:(NSCoder *)aDecoder { METHOD; self = [super initWithCoder:aDecoder]; if (self) { // Initialization code self.customLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 40)]; [self addSubview:self.customLabel]; } return self; } </code></pre> <p>In your tableViewController's .m file, in the method tableView:cellForRowAtAtIndexPath:</p> <pre><code>theCell.customLabel.frame = CGRectMake(0, 0, 320, 40); theCell.customLabel.text = @"Whatever text you want"; </code></pre> <p>This will give you instant and complete control over your custom label right when the tableview and cell loads.</p> <p>In response to @inafziger, I tried programmatically removing the constraints on the label but it did not resolve this auto-resizing issue.</p> <p>Update: making a temporary reference to the subview, then removing it from superview, and then adding it back to the subview, this worked just as well, with the slight exception that the in my case where I'm using a label, the height of the label was fit to the height of the text it contained (whereas programmatically creating the label in my example above, the label will have whatever height you assign it.) The advantage being that you don't have to create any custom labels, or even touch the subclass tableviewCell. Just use whatever you created in storyboard. Here's tableView:cellForRowAtIndexPath:</p> <pre><code>UILabel *theLabel = theCell.theLabel; [theCell.theLabel removeFromSuperview]; [theCell addSubview:theLabel]; theCell.theLabel.frame = CGRectMake(0, 0, 320, 40); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload