大佬教程收集整理的这篇文章主要介绍了ios – 可变高度UITableViewCell在滚动到列表结尾并旋转后展开,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我知道造成这种奇怪的布局的原因是什么.它是附件(UITableViewCellAccessory)的设置.如果我停止指定附件,布局不会中断.我没有添加这个作为答案,因为答案需要一个解决方案,给我一个配件,而不打破布局
我看到人们使用动态高度自定义单元的大多数问题是它们在旋转之前没有正确的高度.但是我看到了相反的情况:所有单元格的高度都适用于其动态内容.向上和向下滚动不会破坏这一点.但是,如果我滚动到列表的底部,然后旋转设备,然后向后旋转一行将成为屏幕高度的0.5到1.5倍.
进一步旋转或进一步滚动将使行返回到期望高度.我在屏幕截图之前和之后都包含了几个
UITableView的定义如下
this.rootChildrenTable = new UITableView() { TranslatesAutoresizingMaskIntoConsTraints = false,AccessibilityIdentifier = "rootChildrenTable",RowHeight = UITableView.AutomaticDimension,EstimatedRowHeight = 44.0f,BACkgroundColor = UIColor.GroupTableViewBACkgroundColor,TableFooterView = new UIView(),TableHeaderView = this.searchBar,KeyboardDismissMode = UIScrollViewKeyboardDismissMode.onDrag };
注意通常的嫌疑人是RowHeight和EstimatedRowHeight.@R_616_11179@从标签中删除Lines = 0,使行的高度相同,问题就会消失.
知道还有什么我应该看的吗?
//calculate the height by this way override func tableView(_ tableView: UITableView,heightForRowAt indexPath: IndexPath) -> CGFloat { return self.heightForBasicCell(at: indexPath) } func heightForBasicCell(at indexPath: IndexPath) -> CGFloat { var sizingCell: YourCell? = nil var onCEToken: dispatch_once_t dispatch_once(onCEToken,{() -> Void in sizingCell = tableView.dequeueReusableCell(withIdentifier: YourCell.cellIdentifier())! }) self.configureBasicCell(sizingCell,at: indexPath) return self.calculateHeight(forConfiguredSizingCell: sizingCell) } func calculateHeight(forConfiguredSizingCell sizingCell: YourCell) -> CGFloat { sizingCell!.bounds = CGRect(x: 0.0,y: 0.0,width: CGRectGetWidth(tableView.framE),height: CGRectGetHeight(sizingCell!.bounds)) sizingCell!.setNeedsLayout() sizingCell!.layoutIfNeeded() var size = sizingCell!.contentView.systemLayoutSizeFitTingSize(UILayoutFitTingCompressedSizE) return size.height + 1.0 // Add 1.0f for the cell separator height } func configureBasicCell(_ cell: YourCell,at indexPath: IndexPath) { //set your text here cell(“text”) }
以上是大佬教程为你收集整理的ios – 可变高度UITableViewCell在滚动到列表结尾并旋转后展开全部内容,希望文章能够帮你解决ios – 可变高度UITableViewCell在滚动到列表结尾并旋转后展开所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。