2016-11-01 115 views
1

我有一个swift中的iMessage扩展,当用户点击一个按钮时,它位于展开的presentationStlye中。一旦点击该按钮,应该完全消除该视图或至少返回到紧凑模式。我不知道什么是错的。这里是正在didTransition从我的按钮叫:关闭消息视图控制器

self.didTransition(to: MSMessagesAppPresentationStyle.compact) 

和行动:

override func didTransition(to presentationStyle: MSMessagesAppPresentationStyle) { 

    guard presentationStyle == .expanded else { return } 
    self.dismiss(animated: true) { 

    } 
} 

但是,这是行不通的。有谁知道我做错了什么?

回答

0

这些功能将有助于从一个过渡态移动到另一个MSMessagesViewController: -

requestPresentationStyle(.expanded)  
requestPresentationStyle(.compact) 

以上方法将调用willTransition和didTransition: -

override func willTransition(to presentationStyle: MSMessagesAppPresentationStyle) { 

//这里我们可以检查presentationStyle并根据需要移动控制器。即

let controller: UIViewController 
    if presentationStyle == .compact { 
     controller = instantiateCompactController() 
    } 
    else { 
     controller = instantiateExpandController() 
    } 
    //and then Present Controller 
    } 

更多信息:https://developer.apple.com/videos/play/wwdc2016/224/

相关问题