Question

Im making a messaging app that works like most messaging apps so that you can view multiple conversations by looking at a table view made up of cells containing the person or group you are messaging. The problem I am running into is how to generate another view controller for when you select the conversation you wish to enter. How do you do this? Do you generate a separate view controller for each cell? OR Do you make a template view controller that grabs the conversation and user information from the backend and enters it into that template view controller?

I can not find this on the internet nor a github ios messaging project that is updated enough to actually work in xcode. If somebody could help me out with this then that would be great! Thanks!

Was it helpful?

Solution

There are a lot of different ways to do this, but each cell in your messaging app's main view should have some reference tied to it knowing what conversation it is, you can make a UITableViewCell subclass that has a messageID property of some sort. Then, in didSelectRowAtIndexPath in your main view, grab the cell's messageID value and pass it to a UITableViewController and push it. In viewDidLoad of your UITableViewController, you will do your logic to retrieve the data for message thread and then display everything accordingly.

OTHER TIPS

A typical way to do this is have a UIViewController subclass for displaying a conversation. When the user selects a conversation from the list, you select the appropriate model that represents this conversation and create a new conversation view controller that will display the contents.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top