我在UITableview的xcode 6中使用自动调整大小,但无法正常工作。我想使用自动调整大小。我从 Storyboard 中的UITableviewController类的静态单元格中添加了文本字段。屏幕外的文本字段为横向或纵向。我不想使用autolayout我的整个项目都在自动调整大小。
Demo Project
最佳答案
我最近有同样的问题。我在UITableViewCell的内容 View 中以及每次隐藏时都添加了标签(x >> 320)。我意识到问题出在源代码XML中。
XML是:
<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"/>
要解决我的问题,只需将“tableViewCell”和“tableViewCellContentView”更改为:
<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"/>
和
<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"/>
所以,问题解决了!希望对您有帮助。
关于uitableview - Xcode 6中的UITableView中的自动调整大小问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26230247/