Ios 无法创建带有自定义约束的标签浏览器
我用于在iMessage extension中创建标签浏览器的代码是:Ios 无法创建带有自定义约束的标签浏览器,ios,swift,imessage-extension,Ios,Swift,Imessage Extension,我用于在iMessage extension中创建标签浏览器的代码是: func createStickerBrowser() { let controller = MSStickerBrowserViewController(stickerSize: .small) view.translatesAutoresizingMaskIntoConstraints = false addChildViewController(controller) view.a
func createStickerBrowser() {
let controller = MSStickerBrowserViewController(stickerSize: .small)
view.translatesAutoresizingMaskIntoConstraints = false
addChildViewController(controller)
view.addSubview(controller.view)
controller.stickerBrowserView.dataSource = self
controller.view.backgroundColor = UIColor.green
let leading = NSLayoutConstraint(item: controller.view, attribute: .leading, relatedBy: .equal, toItem: view, attribute: .leading, multiplier: 1, constant: 0)
let trailing = NSLayoutConstraint(item: controller.view, attribute: .trailing, relatedBy: .equal, toItem: view, attribute: .trailing, multiplier: 1, constant: 0)
let bottom = NSLayoutConstraint(item: controller.view, attribute: .bottom, relatedBy: .equal, toItem: view, attribute: .bottom, multiplier: 1, constant: 0)
let top = NSLayoutConstraint(item: controller.view, attribute: .top, relatedBy: .equal, toItem: view, attribute: .top, multiplier: 1, constant: 0)
view.addConstraints([leading, trailing, top, bottom])
}
但我的故事板是这样的:
为什么不将其添加到视图层次结构中?我需要把它放在按钮旁边。按钮是固定的,但标签浏览有自己的滚动条。如何执行此操作?放置或替换MSMessageAppViewController类的ViewWillDisplay方法:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
requestPresentationStyle(.expanded)
}