SwiftKickMobile / SwiftMessages

A very flexible message bar for UIKit and SwiftUI.
MIT License
7.3k stars 742 forks source link

How to present view controller in SwiftMessages without storyboard? #381

Closed ryanzzff closed 4 years ago

ryanzzff commented 4 years ago

I found SwiftMessagesSegue example in the Demo, but it is using segue that seems can only be used with storyboard. In my project, I'm using separate xib for each view controllers, how can I add the view controllers in the MessageView of SwiftMessages?


What am I trying to do is have a UINavigationViewController with dynamic height, depends on the height of the child view controller.

e.g. I have a SwiftMessagesMessageView --UINavigationViewController

-- TableViewController (root view controller) | -- ItemDetailViewController (push when table view cell is selected)

When the TableViewController is shown, update the height constraint of MessageView.backgroundView to the content size of the TableView,

When the item is selected in the table view, I may want a nearly full-page layout, e.g. screen height - 100, so update the height of MessageView.backgroundView again.

When the back button in ItemDetailViewController is clicked, update the height of MessageView.backgroundView

So another question, how can I can the reference/instance of the MessageView from the view controller inside the UINavigationViewController?

wtmoose commented 4 years ago

First, the segue can be used programmatically. Check the docs. Second, you don’t need to access the message view. By default, the message view sizes to fit the content. You can add height constraint on your navigation controller and adjust it as needed.