Search code examples
iosswiftsegueimessageimessage-extension

iMessage App Expanded View Programmatically


I have the code below to handle the resizing when the user taps on the arrow in my iMessage app to transition to the expanded view, but how can I open the expanded view programmatically when the user segues to a new view controller in my iMessage app?

override func didTransition(to presentationStyle: MSMessagesAppPresentationStyle) {
    // Called after the extension transitions to a new presentation style.

    if presentationStyle == MSMessagesAppPresentationStyle.compact {
        //Resize Views
    }
}

Solution

  • Assuming that you are calling this in MessagesViewController, you can programatically open the expanded view in the following way:

    Swift version:

    if self.presentationStyle == MSMessagesAppPresentationStyle.compact {
        self.requestPresentationStyle(MSMessagesAppPresentationStyle.expanded)
    }
    

    Obj-C version:

    if (self.presentationStyle == MSMessagesAppPresentationStyleCompact) {
        [self requestPresentationStyle:MSMessagesAppPresentationStyleExpanded];
    }