【问题标题】:Half screen and full screen bottom sheet with material components for iOS (swift)带有iOS材质组件的半屏和全屏底页(swift)
【发布时间】:2018-12-20 19:40:56
【问题描述】:

我正在使用 iOS 的材料组件来制作可拖动的底部工作表,该工作表启动半屏(预览模式),您可以拖动到全屏。但是我不知道怎么做,文档也不是很完整。 https://material.io/develop/ios/components/bottom-sheet/

我在 MDCBottomSheetController 中展示我的 DetailViewController:

let graphDetailViewController = UIStoryboard.detail().instantiateViewController(withIdentifier: "DetailViewController") as! DetailViewController     
let bottomSheet: MDCBottomSheetController = MDCBottomSheetController(contentViewController: graphDetailViewController)
bottomSheet.preferredContentSize = CGSize(width: self.view.frame.size.width, height: self.view.frame.size.height / 2)
    present(bottomSheet, animated: true, completion: nil)

使用此代码,我的 vc 显示为半屏,但无法将其拖动到全屏。

有没有人对 iOS 的材料组件(底页)有经验并且可以帮助我?

非常感谢!

【问题讨论】:

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


    【解决方案1】:

    除了将preferredContentSize 设置为屏幕高度的 1/2 之外,一切都正确。

     bottomSheet.preferredContentSize = CGSize(width: self.view.frame.size.width, height: self.view.frame.size.height / 2)
    

    是导致您的错误的行。该行告诉底部表格没有更多内容可滚动。你可以删除它。如果您想让 contentViewController 成为滚动视图,您可能需要使用 trackingScrollView 属性。

    【讨论】:

    • 那么,您使用trackingScrollView 而不是contentViewController?如果没有,你在哪里定义你的滚动视图?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-20
    • 2014-05-01
    • 2014-11-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多