当前位置: 首页 > news >正文

Advanced Auto Layout:Working with Self-Sizing Table View Cells

Working with Self-Sizing Table View Cells使用自缩放表视图单元格

In iOS, you can use Auto Layout to define the height of a table view cell; however, the feature is not enabled by default.

在iOS,你可以使用自动布局to define the height of a table view细胞。However,the by default is not功能特征。

Normally, a cell’s height is determined by the table view delegate’s tableView:heightForRowAtIndexPath:method. To enable self-sizing table view cells, you must set the table view’s rowHeight property to UITableViewAutomaticDimension. You must also assign a value to the estimatedRowHeight property. As soon as both of these properties are set, the system uses Auto Layout to calculate the row’s actual height. 

一般情况下,细胞的高度is determined by the table view:heightforrowatindexpath:tableview委托的方法。自测量表观to enable the table),你必须设置视图的rowheight to uitableviewautomaticdimension物业。You must also to the estimatedrowheight值指定为属性。as soon as both of these are set),the system to calculate the使用自动布局当前行的高度。

  1. tableView.estimatedRowHeight = 85.0
  2. tableView.rowHeight = UITableViewAutomaticDimension

Next, lay out the table view cell’s content within the cell’s content view. To define the cell’s height, you need an unbroken chain of constraints and views (with defined heights) to fill the area between the content view’s top edge and its bottom edge. If your views have intrinsic content heights, the system uses those values. If not, you must add the appropriate height constraints, either to the views or to the content view itself.

接下来,在单元格内容视图中列出表视图单元格的内容。要定义单元格的高度,需要一个完整的约束和视图(定义高度),以填充内容视图的顶部边缘和底部边缘之间的区域。如果您的视图具有内在内容高度,则系统使用这些值。如果不是,则必须向视图或内容视图本身添加适当的高度限制。

image: ../Art/Chain_of_Views_and_Constraints_2x.png

Additionally, try to make the estimated row height as accurate as possible. The system calculates items such as the scroll bar heights based on these estimates. The more accurate the estimates, the more seamless the user experience becomes.

此外,尽量使估计行高度尽可能准确。系统根据这些估计计算滚动条高度等项。估计越准确,用户体验越无缝。

NOTE

When working with table view cells, you cannot change the layout of the predefined content (for example, the textLabeldetailTextLabel, and imageView properties).

使用表格视图单元格时,您不能更改预定义内容布局(例如,在textlabel,detailtextlabel ImageView,和性能)。

The following constraints are supported:支持以下约束:

  • Constraints that position your subview relative to the cell’s content view.约束你的子视图的相对位置的单元格的内容视图。

  • Constraints that position your subview relative to the cell’s bounds.约束你的视图位置相对于细胞的界限。

  • Constraints that position your subview relative to the predefined content.约束你的视图位置相对于预定义的内容。

转载于:https://www.cnblogs.com/zyingn/p/AdvancedAutoLayout__WorkingWithSelfSizingTableViewCells.html

相关文章:

  • 震精 - PostgreSQL 单机3.9 万亿/天(计数器、序列、自增)
  • 什么是 SHTML
  • mysql57修改root密码
  • python3编码问题终结者--还搞不懂你来找我
  • Python(三)之Python的表达式和语句概述
  • # 20155222 2016-2017-2 《Java程序设计》第5周学习总结
  • 消息中间件简介
  • 画像分析(4-1)智能搬迁和数据订阅
  • Bzoj4771 七彩树
  • Oracle 数据库备份脚本
  • C8051F340 USB Fn hacking
  • Android Studio 开始运行错误
  • 对象——浅识
  • Hadoop单机版快速搭建及测试
  • Android开源项目规范总结
  • 时间复杂度分析经典问题——最大子序列和
  • [NodeJS] 关于Buffer
  • 2018以太坊智能合约编程语言solidity的最佳IDEs
  • Apache的基本使用
  • Fundebug计费标准解释:事件数是如何定义的?
  • JavaScript中的对象个人分享
  • 分布式任务队列Celery
  • 精彩代码 vue.js
  • 每个JavaScript开发人员应阅读的书【1】 - JavaScript: The Good Parts
  • 实战:基于Spring Boot快速开发RESTful风格API接口
  • 腾讯优测优分享 | 你是否体验过Android手机插入耳机后仍外放的尴尬?
  • 微信如何实现自动跳转到用其他浏览器打开指定页面下载APP
  • 问题之ssh中Host key verification failed的解决
  • 做一名精致的JavaScripter 01:JavaScript简介
  • 关于Android全面屏虚拟导航栏的适配总结
  • ​LeetCode解法汇总1276. 不浪费原料的汉堡制作方案
  • #LLM入门|Prompt#2.3_对查询任务进行分类|意图分析_Classification
  • #NOIP 2014#day.2 T1 无限网络发射器选址
  • #pragma multi_compile #pragma shader_feature
  • #我与Java虚拟机的故事#连载03:面试过的百度,滴滴,快手都问了这些问题
  • (多级缓存)缓存同步
  • (附源码)计算机毕业设计SSM在线影视购票系统
  • (三)终结任务
  • (转)IIS6 ASP 0251超过响应缓冲区限制错误的解决方法
  • (转载)深入super,看Python如何解决钻石继承难题
  • .NET 8 中引入新的 IHostedLifecycleService 接口 实现定时任务
  • .NET Core、DNX、DNU、DNVM、MVC6学习资料
  • .Net Winform开发笔记(一)
  • .net 后台导出excel ,word
  • .netcore 如何获取系统中所有session_ASP.NET Core如何解决分布式Session一致性问题
  • /bin、/sbin、/usr/bin、/usr/sbin
  • :“Failed to access IIS metabase”解决方法
  • [AndroidStudio]_[初级]_[修改虚拟设备镜像文件的存放位置]
  • [codevs 2822] 爱在心中 【tarjan 算法】
  • [Flex] PopUpButton系列 —— 控制弹出菜单的透明度、可用、可选择状态
  • [GN] DP学习笔记板子
  • [GN] Vue3快速上手1
  • [Hadoop in China 2011] Hadoop之上 中国移动“大云”系统解析
  • [hdu 3065] 病毒侵袭持续中 [AC自动机] [病毒特征码匹配]
  • [JavaScript]如何讓IE9, IE8, IE7, IE6關閉視窗時不彈出對話訊息