2016-12-27 67 views
0

我使用的iMessage擴展創建標籤瀏覽器的代碼是:無法創建自定義的約束貼紙瀏覽器

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]) 
} 

enter image description here

但我的故事板是這樣的:

enter image description here

爲什麼它不被添加到視圖層次?我需要把它放在按鈕旁邊。按鈕是固定的,但不乾膠標籤瀏覽有自己的滾動。這個怎麼做? MSMessagesAppViewController類的

回答

0

穿戴或替換viewWillAppear中方法:

override func viewWillAppear(_ animated: Bool) { 
    super.viewWillAppear(animated) 

    requestPresentationStyle(.expanded)   
}