我正在尝试使用tableVIEw和动态高度行创建Feed列表.
tableVIEw是可滚动的,但UItableVIEwWrapperVIEw看起来不会改变它的大小!
下面是视图层次结构的代码和截图.
我觉得很奇怪
码:
class FeedController: UItableVIEwController { var items: NSMutableArray = [] overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() refreshControl?.addTarget(self,action: "FeedLoad",forControlEvents: UIControlEvents.ValueChanged) self.FeedLoad() } overrIDe func tableVIEw(tableVIEw: UItableVIEw,estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGfloat { return 120.0 } overrIDe func tableVIEw(tableVIEw: UItableVIEw,heightForRowAtIndexPath indexPath: NSIndexPath) -> CGfloat { println("called") return UItableVIEwautomaticDimension } overrIDe func tableVIEw(tableVIEw: UItableVIEw,numberOfRowsInSection section: Int) -> Int { return self.items.count } overrIDe func tableVIEw(tableVIEw: UItableVIEw,cellForRowAtIndexPath indexPath: NSIndexPath) -> UItableVIEwCell { return self.getCellForItemAtIndexPath( indexPath ) } func getCellForItemAtIndexPath(indexPath: NSIndexPath) -> UItableVIEwCell { let item: Dictionary = self.items[indexPath.row] as Dictionary<String,AnyObject> let cell = tableVIEw.dequeueReusableCellWithIDentifIEr( (item["type"] as String) + "Cell",forIndexPath: indexPath ) as FeedVIEwCell cell.fillData(item) return cell as UItableVIEwCell } func FeedLoaded(){ tableVIEw.reloadData() } func FeedLoad(){ // Feed Load Logic which will call next line once Feed loaded self.FeedLoaded() }}解决方法 我假设你为你的单元格配置了自动布局,因为这是唯一的方式来使其工作.自动布局应该能够根据您的单元格限制来计算高度.
因此,您应该在垂直视图之间以及超视图(在这种情况下为单元格视图)的顶部和底部边缘的视图之间存在约束.
假设你有一个标题和描述的单元格,像这样:
|------------------|| Title || || Description with || long multiple || lines of text ||------------------|
在这个例子中,你必须设置一个在标题和描述之间的垂直空间的约束,标题的顶部和单元格视图顶部之间的垂直空间的约束以及描述底部和单元格视图底部之间的垂直空间.
总结以上是内存溢出为你收集整理的ios – 如果行高度为UITableViewAutomaticDimension,则UITableViewWrapperView的大小不会随内容而改变全部内容,希望文章能够帮你解决ios – 如果行高度为UITableViewAutomaticDimension,则UITableViewWrapperView的大小不会随内容而改变所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)