2016-11-01 113 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/

相關問題