久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

滾動視圖中的動態高度 TableView

Dynamic height TableView in a Scroll View(滾動視圖中的動態高度 TableView)
本文介紹了滾動視圖中的動態高度 TableView的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在設計一個具有滾動視圖的頁面,其上方是一個表格視圖(禁用滾動).為此,我在這個問題中提到了答案 - 使 UITableView 不可滾動并調整高度以適應所有單元格,但沒有成功.

I am designing a page having a scroll view and above it a table view(scroll disabled). For doing this I have referred answers in this question - Make UITableView not scrollable and adjust height to accommodate all cells ,but wasn't successful.

視圖的層次結構以及提供的約束-

Hierarchy of views along with provided constraints-

-主視圖

-滾動視圖
固定到主視圖的所有側面(0,0,0,0),限制到邊距

-Scroll view
pinned to all sides of main view(0,0,0,0), constraint to margins

-內容視圖

固定到滾動視圖(0,0,0,0),與主視圖等寬,與主視圖等高(優先級 - 250)

pinned to scroll view(0,0,0,0),equal width to main view,equal height to main view(priority - 250)

-內容視圖內的表格視圖

滾動禁用,從四面八方有50個點空間,高度(> =),底部間距50(關系> =).我已經把大于等于,以便動態增加高度.

scroll disabled,having 50 point spaces from all sides,Height(>=),bottom spacing 50(relation >=).I have put greater than equal so as to increase height dynamically.

現在,當我填充表格視圖時,我將代碼用作

Now when I populate my table view I use the code as

 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
    {
        let cell = tableview.dequeueReusableCellWithIdentifier("cellreuse", forIndexPath: indexPath) 
        cell.textLabel?.text = name[indexPath.row]

        tableview.frame.size = tableview.contentSize

        return cell
    }

因此,當我運行我的代碼時,它會增加 tableview 框架但不會拉伸內容大小,而且它會變得很奇怪,因為我的滾動視圖不會滾動到 table view 的末尾,我的 table view 也不服從自動布局約束.

So when I run my code, it increases the tableview frame but doesn't stretch the content size and it just becomes weird as my scroll view doesn't scroll to the end of the table view neither my table view obeys the auto layout constraints.

推薦答案

只是我需要這樣做 -

Just I needed to do this -

  • 去掉這一行 - tableView.frame.size = tableView.contentSize

為表格視圖添加高度約束.

Add a height constraint for table view.

將優先級設置為高

創建一個高度約束的出口(Ctrl+Drag).

Create an outlet of the height constraint(Ctrl+Drag).

無論您需要在何處重新加載表格數據,請將高度約束設置為表格視圖的內容高度.

Wherever you need to reload data of your table, set the height constraint to tableview's content height.

tableHeightConstraint.constant = tableview.contentSize.height

這篇關于滾動視圖中的動態高度 TableView的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

UIButtons at the bottom of UIScrollView not working(UIScrollView 底部的 UIButtons 不起作用)
scrollViewWillEndDragging:withVelocity:targetContentOffset: not working on the edges of a UISCrollView(scrollViewWillEndDragging:withVelocity:targetContentOffset: 不在 UISCrollView 的邊緣工作) - IT屋-程序員軟件開發技術分享社
ImageView Scaling when scrolling down(向下滾動時 ImageView 縮放)
Bounds automatically changes on UIScrollView with content insets(UIScrollView 上的邊界自動更改,帶有內容插圖)
iOS5 UITapRecognizer for UIScrollView interfering with buttons. How to fix?(用于 UIScrollView 的 iOS5 UITapRecognizer 干擾按鈕.怎么修?)
Handling scroll views with (custom, interactive) view controller presentation and dismissal(使用(自定義、交互式)視圖控制器呈現和解除處理滾動視圖)
主站蜘蛛池模板: 国产一区二区成人 | 欧美aaaaaaaaaa| 91人人爽| 国产精品免费av | 永久免费av | 国产精品污www一区二区三区 | 夜夜撸av| 韩日一区二区 | wwwww在线观看| 亚洲国产一区在线 | a黄在线观看 | 天天久久| 日日操操操 | 日韩电影免费在线观看中文字幕 | 久久99精品久久久久久国产越南 | 黄色在线免费看 | 欧美日韩在线不卡 | 欧产日产国产精品视频 | 精品在线一区 | 一级毛片黄片 | 国产精品一区久久久久 | 在线观看h视频 | 9999在线视频| 国产成人久久精品一区二区三区 | 最新中文字幕在线 | av中文字幕在线 | 成人免费观看男女羞羞视频 | 亚洲成人免费视频 | 五月婷婷 六月丁香 | 精品国产一区二区三区成人影院 | 二区在线视频 | 一区亚洲 | 成人精品在线观看 | 精品久久电影 | 亚洲综合在线一区 | 欧美日韩一区二区视频在线观看 | 色综合久久久 | av日韩高清| 久久久久国色av免费观看性色 | 婷婷色婷婷 | 国产在线一级片 |