0

I am new to IOS development. In my app I want to replace the view model that's being presented. I show my initial view by calling: presentModalViewController

When I replace the view, I don't want the entire animation to run. I just simply want to change the presentModalViewController underlaying view to update.

When I set:

self.presentModalViewController.view = myCustomViewController.view

it works great for the first time, and really does replace the view But when I try doing it again and replace the view's content at some other point in my application's live, the presentModalViewController does not update.

How can I update the view in presentModalViewController

vondip
  • 13,809
  • 27
  • 100
  • 156

1 Answers1

1

It really depends of what you are trying to achieve.

1 - Does the new view has an entirely new behavior? Perhaps using a new UIViewController might be a solution.

2 - If you answer no to the first, then a secondary UIView inside the XIB will do the trick. As long as you have access to it with an IBOUtlet.


Edit 1:

I show my initial view by calling: presentModalViewController

If you are showing it (that's where you are), your course of action should be inside of it, and not outside. For instance:

self.view = mySecondaryView;
Rui Peres
  • 25,741
  • 9
  • 87
  • 137
  • I see, well It is a completely new course of action. thing is that if I call presentModalViewController again, this time on my new UIViewController i get a delayed view loaded. I want it to just 'replace' or update the current view – vondip May 29 '12 at 15:07
  • Again, if you don't need a special behavior, just add the `UIView` you want to be used inside your XIB. Then it's a simple. – Rui Peres May 29 '12 at 15:08