Reputation: 1490
I was trying to integrate my app with material-components
called bottomSheet
. When i implement that component it shown me correctly but not like what i expected.
When it shown up and all the time i scroll up that bottomSheet does not stick to bottom of view
How to fix this particular issue?
Here is the code
let viewController: UIViewController = UIViewController()
viewController.view.backgroundColor = .red
let bottomSheet: MDCBottomSheetController = MDCBottomSheetController(contentViewController: viewController)
self.present(bottomSheet, animated: true, completion: nil)
Upvotes: 2
Views: 1608
Reputation: 670
Why don't add some contents of that particular viewController.
Create tableViewController
import Foundation
import UIKit
class TableViewContent: UITableViewController {
let cellId = "CellId"
override func viewDidLoad() {
super.viewDidLoad()
tableView.register(UITableViewCell.self, forCellReuseIdentifier: cellId)
}
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: cellId, for: indexPath)
cell.textLabel?.text = "Hello World"
return cell
}
}
After created that controller then add this in your code that you provided:
// let viewController: UIViewController = UIViewController()
//
// viewController.view.backgroundColor = .red
// let size = viewController.view.sizeThatFits(view.bounds.size)
// let viewFrame = CGRect(x: 0, y: 0, width: size.width, height: size.height)
// viewController.view.frame = viewFrame
let viewController = TableViewContent()
let bottomSheet: MDCBottomSheetController = MDCBottomSheetController(contentViewController: viewController)
self.present(bottomSheet, animated: true, completion: nil)
Hope this will help... The reason it not stick to bottom because the controller is empty, just my idea...
Upvotes: 1