0

I have two view controllers which should work like described below:

First view controller displays a view which has a table in it. The table contains data which is constantly changing. I have a delegate method for reloading the data when a change occurs. So that is taken care of. When the user selects a row in the table I would like to display a second view which would also contain live data in text format (one UITextView which would constantly change).

I would like to allow the user to access view 1 while view 2 would still be monitoring and displaying live data and vice versa. While user is on view 2, view 1 should still be monitoring and displaying any changes in the table content.

I guess its like having two view controllers present at the same time and switching between them.

What is the easiest or the most standard way to accomplish this? I dont mind if its all done programatically.

Majster
  • 3,611
  • 5
  • 38
  • 60

2 Answers2

0

what you have is a problem where you need a custom parentviewcontroller look into splitviews as one example :: SplitView like Facebook app on iPhone

cool intros of how to do custom container view controllers :: Container View Controller Examples

Community
  • 1
  • 1
Daij-Djan
  • 49,552
  • 17
  • 113
  • 135
  • These are all views that appear like on the photo right? I need a total shift to another view. First view 1 then view 2 and back to 1 now back to 2 and so on. Can this be achieved using those side menus? – Majster Nov 11 '12 at 14:58
0

It's a little hard to tell what you're asking here. First, views shouldn't be processing data at all -- they should only be displaying it. It sounds like what you're describing is having a background process that updates to your second view. That process could certainly be running while your table is on screen, and when you switch to the second view, you can update it using this running process. Exactly how you would do this depends on the details of what you're trying to do. So, I think we could help you better if you provide more context on what kind of process you want going on that updates your second view, and how choosing a row in your table affects that process.

After Edit:

You can certainly do what you want to do. I think the main thing is that you need to have a property (typed strong) in your first view controller that points to your second view controller, so that when you go back to the second controller a second time, it goes back to the same instance. Based on the selection from the table, you can start whatever process you need to populate your text view, and that process can keep running even after you go back to the table view, since that controller won't get deallocated when it's view goes off screen (due to the strong reference you have). You would just have to have some sort of if clause in your second view controller to know whether the user has selected the same row again, and if so, just show the updated text view, rather than starting a new process.

That's about as specific as I can be without more detail from you.

rdelmar
  • 103,982
  • 12
  • 207
  • 218
  • @Majster, this is still not clear -- do you need both views to be on the screen at the same time or not? From you first post, it sounded like you wanted to switch between them, and now it sounds like you want them both on screen at the same time. Which is it? This line: "While user is on view 2, view 1 should still be monitoring and displaying any changes in the table content." says you want them both on screen at the same time. – rdelmar Nov 11 '12 at 18:09
  • No, I also wrote "I guess its like having two view controllers present at the same time and switching between them.". I want one view at a time on the screen, but on the switch the other one should be updated. – Majster Nov 11 '12 at 18:12
  • @Majster, ok, that clears that up, but it's still hard to give you more specific advice without knowing whether the data in the 2 views affect each other. When a user selects a row, and you then show the second view, how does that selection affect what is being shown in view 2? What is the relationship between the data sets being presented in those 2 views? – rdelmar Nov 11 '12 at 18:16
  • The first view is the "independent" view. It displays a table from which user chooses the item he wants to know more about. The second view loads the data dependant on the user's choice. The data is then updated every time a change occurs. I want to present the second view and still keep it "live in the background" if the user shifts back to view one. Is that understandable enough? – Majster Nov 11 '12 at 18:29
  • Great! Thanks! I just have one side question. Strong keyword means that the property doesnt get deallocated? And since its not deallocated it "works in the background"? Is this some sort of C++ static? – Majster Nov 11 '12 at 19:55
  • 1
    No, it's just objective-c memory management. As long as you have a strong reference to something it won't get deallocated. As far as working in the background that's something you can do with any object as long as it exists, but having a strong reference to an object doesn't mean it has to work in the background. In this context, "background" just means the controller's view is not on screen. – rdelmar Nov 11 '12 at 21:13