Search code examples
uitableviewios7storyboardxcode6autoresizingmask

Auto resizing issue in UITableView in Xcode 6


I am using auto resizing in xcode 6 in UITableview but it is not working properly. I want to use autoresizing.I have added textfield in static cell in UITableviewController class from storyboard. Textfield beyond the screen either in landscape or portrait. I dont want use autolayout my whole project is in autoresizing. Textfield

Demo Project


Solution

  • I had the same problem recently. I added a label in my UITableViewCell's content view and every time it's hide (x >> 320). I realized that the problem was in the SOURCE CODE XML.

    The XML was:

    <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="InvoiceCell" rowHeight="60" id="B9T-xx-TCx" customClass="InvoiceCell"> 
        // My custom cell is 60 height
        <rect key="frame" x="0.0" y="0.0" width="320" height="44"/> 
        // Wrong Autoresizing
        <autoresizingMask key="autoresizingMask"/> 
        <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="B9T-xx-TCx" id="nvL-MG-mGs">
            //No rect frame and wrong autoresizing mask
            <autoresizingMask key="autoresizingMask"/>
    

    To solve my problem is just change "tableViewCell" and "tableViewCellContentView" to:

    <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="InvoiceCell" rowHeight="60" id="B9T-xx-TCx" customClass="InvoiceCell"> 
        //Add/change this 2 lines in <tableViewCell>
        <rect key="frame" x="0.0" y="0.0" width="320" height="60"/>
        <autoresizingMask key="autoresizingMask" widthSizable="YES"/>
    

    and

    <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="B9T-xx-TCx" id="nvL-MG-mGs">
        //Add/change this 2 lines in <tableViewCellContentView>
        <rect key="frame" x="0.0" y="0.0" width="320" height="60"/>
        <autoresizingMask key="autoresizingMask" widthSizable="YES"/>
    

    So, problem solved! I hope this help you guys.