0

I have a UITableViewController with a set of static UITableViewCells with some dynamic content, but after upgrading to XCode 7, the cells are not resizing anymore, and the content overlaps the cells below. I noticed the following 'rect' tags are added to the storyboard.

<rect key="frame" x="8" y="8" width="584" height="584"/>

The content inside the cell, is a UIImageView with a 1:1 ratio constraints, so that it always stick to the sides and is resized in height.

Constraints for the UITableViewCell.

<tableViewCell userInteractionEnabled="NO" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="TeM-3R-AKy">
                                    <rect key="frame" x="0.0" y="124" width="600" height="44"/>
                                    <autoresizingMask key="autoresizingMask"/>
                                    <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="TeM-3R-AKy" id="Ul9-Ad-TSI">
                                        <rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
                                        <autoresizingMask key="autoresizingMask"/>
                                        <subviews>
                                            <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" restorationIdentifier="yolo" translatesAutoresizingMaskIntoConstraints="NO" id="Dno-dR-6h7">
                                                <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
                                                <animations/>
                                                <constraints>
                                                    <constraint firstAttribute="width" secondItem="Dno-dR-6h7" secondAttribute="height" multiplier="1:1" id="4gQ-ye-O6k"/>
                                                    <constraint firstAttribute="height" priority="999" constant="60" id="cBT-jH-WiC"/>
                                                </constraints>
                                            </imageView>
                                        </subviews>
                                        <animations/>
                                        <constraints>
                                            <constraint firstAttribute="trailing" secondItem="Dno-dR-6h7" secondAttribute="trailing" id="0K4-U7-ueq"/>
                                            <constraint firstItem="Dno-dR-6h7" firstAttribute="leading" secondItem="Ul9-Ad-TSI" secondAttribute="leading" id="2ER-Tt-FFc"/>
                                            <constraint firstAttribute="bottom" secondItem="Dno-dR-6h7" secondAttribute="bottom" priority="999" id="jfg-iH-H9u"/>
                                            <constraint firstItem="Dno-dR-6h7" firstAttribute="top" secondItem="Ul9-Ad-TSI" secondAttribute="top" id="mcU-xf-gfx"/>
                                        </constraints>
                                    </tableViewCellContentView>
                                    <animations/>
                                </tableViewCell>

Possible duplicate of: iOS8 self-sizing static TableView cells with Interface Builder

Community
  • 1
  • 1
Erlend
  • 1,711
  • 1
  • 22
  • 25
  • 1
    Reset constraints once and try if you still face the issue. – PK20 Nov 17 '15 at 01:44
  • @PK20 Do you mean reset to suggested? Which constraints are you refering to? I don't think xcode knows what i want to do.. but i tried to reset the constraints of the UIImageView after fitting it into the cell without results. – Erlend Nov 17 '15 at 02:11
  • Not reset to suggested. When you upgraded to Xcode7, the constraints may not have copied properly. It is always better to clear all your constraints and set again. I know it is painful but thats the only way. – PK20 Nov 17 '15 at 02:13
  • Ah. Tried it. Same results. Maybe something has changed in xcode 7, or i'm doing something wrong. – Erlend Nov 17 '15 at 02:34
  • Can you reveal you constraint you set to cell? – vien vu Nov 17 '15 at 02:36
  • I added constraints @vienvu – Erlend Nov 17 '15 at 03:17

1 Answers1

0

It seems this was a similar problem as discussed in: iOS8 self-sizing static TableView cells with Interface Builder

In order to have static UITableViewCell's automatically resize based on it's content, you have to add the lines mentioned in: iOS8: Possible to use “tableview.rowHeight = UITableViewAutomaticDimension” for static cells?

Community
  • 1
  • 1
Erlend
  • 1,711
  • 1
  • 22
  • 25