2

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

Here it looks like enter image description here

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)
Visal Sambo
  • 1,270
  • 1
  • 19
  • 33

1 Answers1

1

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...

I Love Coding
  • 580
  • 5
  • 13
  • Hello I need help on this ,Same above issues i am facing with CollectionViewController,And if i am using the tableViewController as Explained above everything works fine as expected. – Sandeepk2r May 02 '19 at 10:48