MDCBottomSheetController软键盘避免按向上查看

时间:2019-06-19 13:58:41

标签: ios swift bottom-sheet ios-keyboard-extension material-components-ios

我正在使用MDCBottomSheetController

以下是我介绍底层控制器的代码

 let bottomSheet: MDCBottomSheetController = MDCBottomSheetController(contentViewController: viewController)
    // Present the bottom sheet

    bottomSheet.shouldFlashScrollIndicatorsOnAppearance = true;
    if openFor == SearchBottomSheetViewController.OPEN_FOR_DATE {
        bottomSheet.preferredContentSize = CGSize(width: self.view.frame.size.width, height:  self.view.frame.size.height * 0.3)
    }else {
        bottomSheet.preferredContentSize = CGSize(width: self.view.frame.size.width, height: 3 * self.view.frame.size.height / 4)
    }

    // bottomSheet.dismiss(animated: <#T##Bool#>, completion: <#T##(() -> Void)?##(() -> Void)?##() -> Void#>)
    present(bottomSheet, animated: true, completion: nil)

当显示软键盘时,底部ui被向上推,我不希望在显示键盘时被推起UI

请参阅下面的gif问题

enter image description here

1 个答案:

答案 0 :(得分:-1)

建议的解决方案

增加文本字段顶部约束的常数。

理由

反复试验。