I am trying to configure a simple UITableViewCell in Interface Builder without auto layout. I use old springs and struts.
When I give the label a flexible width, it looks as if the UITableViewCell is much wider, although the UITableViewCell tells me that it has a width of 375 pixels in layoutSubviews :
- (void)layoutSubviews { [super layoutSubviews]; NSLog(@"Label width: %f", self.nameLabel.frame.size.width);
On the simulated iPhone 5S (iOS 7 or 8), the supervisor is 320, but UILabel extends up to 640.
On the simulated iPhone 6, the supervisor is 375, but UILabel extends to 695.
On the simulated iPhone 6 Plus, the supervisor is 414, but UILabel is 734.
I do not have this problem with other views. For example, I can add a UILabel to a UIViewController and stretch the width correctly. What's happening? And how to fix it?
EDIT:
Interestingly, if I add constraints programmatically during cellForRowAtIndexPath: it seems to work as expected, as long as I use the older dequeueReusableCellWithIdentifier instead of dequeueReusableCellWithIdentifier:forIndexPath: However, I want to keep all the restrictions in Interface Builder. Any ideas?
source share