autolayout

Smoothly scrolling tableview up by fixed constant when keyboard appears so last cells are still visible

不羁岁月 提交于 2021-01-28 21:11:57
问题 When the keyboard appears, I am shifting the bottom-most view up by a constant. But due to this the hight of the UITableView also reduces and the cells that were previously visible are no longer visible. What I want to do is scroll the table view up by a height equal to the keyboard's height so that at least the last messages will be visible like they were before the keyboard appeared. The last yellow cell that was half-visible in the image on left should be visible like that on the right too

Dynamic Height of UITableView

余生长醉 提交于 2021-01-27 07:23:14
问题 How to get the Dynamic Height Of UITableView with Constraints. It will increase the UITableView Height depending upon Number of row without adding Scrollbar in table. I'm facing problem in adding the TableView in UIViewController and Height of TableView Should not be Statically fixed. 回答1: The most concise way I've found to do this is by using the contentSize of the table view as the intrinsicContentSize Your tableview needs to be an actual subclass in which you override both contentSize and

Dynamic Height of UITableView

ε祈祈猫儿з 提交于 2021-01-27 07:22:56
问题 How to get the Dynamic Height Of UITableView with Constraints. It will increase the UITableView Height depending upon Number of row without adding Scrollbar in table. I'm facing problem in adding the TableView in UIViewController and Height of TableView Should not be Statically fixed. 回答1: The most concise way I've found to do this is by using the contentSize of the table view as the intrinsicContentSize Your tableview needs to be an actual subclass in which you override both contentSize and

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,

UIDatePicker with .compact style doesn't respect content hugging priority

懵懂的女人 提交于 2021-01-06 03:28:50
问题 I think that the new UIDatePicker (iOS 14+) with the .compact style doesn't work correctly with AutoLayout. Making a simple layout with a UILabel and UIDatePicker where the UIDatePicker has higher content-hugging priority should result in a layout where the UILabel is being stretched if there is too much space available but that's not what happens. That's the result that I get: Here is sample code: class ViewController: UIViewController, UIGestureRecognizerDelegate { private let label:

UIDatePicker with .compact style doesn't respect content hugging priority

流过昼夜 提交于 2021-01-06 03:26:34
问题 I think that the new UIDatePicker (iOS 14+) with the .compact style doesn't work correctly with AutoLayout. Making a simple layout with a UILabel and UIDatePicker where the UIDatePicker has higher content-hugging priority should result in a layout where the UILabel is being stretched if there is too much space available but that's not what happens. That's the result that I get: Here is sample code: class ViewController: UIViewController, UIGestureRecognizerDelegate { private let label:

Why is my VC displaced after changing the Simulator? AutoLayout

回眸只為那壹抹淺笑 提交于 2020-12-15 06:10:16
问题 Hey this is the code I use to set the constraints with auto layout for my View Elements: TimeLabel.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ TimeLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor), TimeLabel.topAnchor.constraint(equalTo: view.topAnchor, constant: -30), TimeLabel.widthAnchor.constraint(equalToConstant: 300), TimeLabel.heightAnchor.constraint(equalToConstant: 300) ]) But it doesn't work! When I change the simulator from iPhone 11 to

Auto-sizing UITableViewCell which contains UICollectionView

南楼画角 提交于 2020-12-12 11:31:33
问题 I am having troubles with an autosizing UITableViewCell which contains a UICollectionView. The view hierarchy is roughly like this UITableViewCell -- Content View ---- Custom View ------ UIStackView (vertical) --------- UILabel --------- UICollectionView (vertical flow layout) When the UITableViewCell is created or reused, the collectionView receives a datasource which it then starts to process. I need all cells of the collectionView to show in the tableViewCell, so I observe changes to the

Auto-sizing UITableViewCell which contains UICollectionView

风流意气都作罢 提交于 2020-12-12 11:31:10
问题 I am having troubles with an autosizing UITableViewCell which contains a UICollectionView. The view hierarchy is roughly like this UITableViewCell -- Content View ---- Custom View ------ UIStackView (vertical) --------- UILabel --------- UICollectionView (vertical flow layout) When the UITableViewCell is created or reused, the collectionView receives a datasource which it then starts to process. I need all cells of the collectionView to show in the tableViewCell, so I observe changes to the