uitableviewautomaticdimension

How to vertically overlap and hide labels in a custom UITableView cell with dynamic height and width to reduce cell size and save space

不问归期 提交于 2021-02-11 12:24:04
问题 I have a messaging cell that has 3 rows of UILabel, 1. Sender Name, 2. Message 3. Sent Time. Initially, I was keeping an offset of 10 between each of the labels. But I realized that I was wasting space in cases where either the message was too small or if the message wrapped over to a new line and had empty space on the right. So I decided to move the label showing sent time up to save some of that space for the case where the message was too small. I constraint the container like this:

How to vertically overlap and hide labels in a custom UITableView cell with dynamic height and width to reduce cell size and save space

馋奶兔 提交于 2021-02-11 12:21:19
问题 I have a messaging cell that has 3 rows of UILabel, 1. Sender Name, 2. Message 3. Sent Time. Initially, I was keeping an offset of 10 between each of the labels. But I realized that I was wasting space in cases where either the message was too small or if the message wrapped over to a new line and had empty space on the right. So I decided to move the label showing sent time up to save some of that space for the case where the message was too small. I constraint the container like this:

UITableView height equal to contentSize height

安稳与你 提交于 2021-01-29 14:08:07
问题 I have a scroll view and inside of if couple labels and a tableView. I would like for that tableView to be scrolled by a outer scrollView and not the tableView's scrollView, so what I did is to set constraint for tableView height to be equal to contentSize height. But I have this problem that it is sized correctly only when push animation is completed (and viewDidLayoutSubviews gets called, I guess) override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() tableHeightConstraint?

Left or right align shouldShowMenuForRowAt menu for a custom UITableView cell

↘锁芯ラ 提交于 2021-01-24 11:14:59
问题 I have a UITableView that I am using for showing chat messages. The cells of this table view are either left or right-aligned and have dynamic width. The menu displayed by shouldShowMenuForRowAt is shown at the horizontal center of the table view cell. Is there a way to shift it to the left or the right edge? func tableView(_ tableView: UITableView, shouldShowMenuForRowAt indexPath: IndexPath) -> Bool { return true } func tableView(_ tableView: UITableView, canPerformAction action: Selector,

Wrong UITableViewCell height for some cells at first loading

↘锁芯ラ 提交于 2020-06-25 04:58:28
问题 I am using UITableViewAutomaticDimension to calculate height for my table view cell. It works fine for me. But for some cells, the height returned is 44 rather than dynamically calculating height. But on scrolling up an looking back to the same cell, the height is recalculated perfectly. So I guess I do not have any faulty constraints because, after I scroll and correct all cell heights manually, no constraint breaking warning are shown afterwards. Edit The below given is the screenshot of

Wrong UITableViewCell height for some cells at first loading

假装没事ソ 提交于 2020-06-25 04:58:08
问题 I am using UITableViewAutomaticDimension to calculate height for my table view cell. It works fine for me. But for some cells, the height returned is 44 rather than dynamically calculating height. But on scrolling up an looking back to the same cell, the height is recalculated perfectly. So I guess I do not have any faulty constraints because, after I scroll and correct all cell heights manually, no constraint breaking warning are shown afterwards. Edit The below given is the screenshot of

Minimum cell height with UITableViewAutomaticDimension

青春壹個敷衍的年華 提交于 2020-06-07 09:45:49
问题 Is it possible to set minimal height for cell? I use dynamic: tableView.estimatedRowHeight = 83.0 tableView.rowHeight = UITableViewAutomaticDimension But I need to set minimal height for cell when my news title label text is in one line. 回答1: Have you tried creating a constraint in your custom UITableViewCell 's view of height >= 60.0 ? 回答2: Got it. Made it work as below. Drag and drop a View on top of UITableViewCell and set constraints Leading, trailing, top and Bottom as 0. Set height

iOS: Dynamic Height For UITableViewCell

浪子不回头ぞ 提交于 2019-12-29 08:48:13
问题 I'm using iOS9 XCode7 I need to change the height of cell Dynamically according to labelText Height I have used: self.tableView.rowHeight=UITableViewAutomaticDimension; But it is not working for custom made cell. sizetoFit is removed in iOS9. Please suggest something. Thanks 回答1: Give your label constrains relative to the cell, top, bottom, left and right. Than your cell size will grow with the content height. also make your label multiline.(by setting Lines property to 0 in attribute

UITableViewAutomaticDimension works not as expected. Swift

百般思念 提交于 2019-12-24 10:48:18
问题 After reading Ray Wenderlich guide for "Self-sizing Table View Cells" as well as this question and answers to it, I've decided to ask all of you for a help. Have a programmically created cell: import UIKit class NotesCell: UITableViewCell { lazy private var cellCaption: UILabel = { let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false label.font = UIFont.systemFont(ofSize: 20, weight: UIFont.Weight.medium) label.numberOfLines = 0 label.lineBreakMode = .byWordWrapping