View A has a button upon clicking it, we go to view B
- View B does not retain a pointer to view A.
- From view B, i’d like to load view A back (programmatically)
Effectively, i’d like to kill B and replace it with A.
I was thinking that the following should work but, it does not
Calling from View B
ViewController *main = [ViewController new];
[self addSubview:[main view]];
What am i missing please?
Personally I think the easiest way to do this would be by having a
UIViewControllerwith anIBOutletto bothUIViewobjects. You can add and design them both in the interface builder and just set one of them (view B) as hidden (it’s a property inUIView).Then, you could specify a button action to toggle the visibility of view B.
I must add though that there are constructs for implementing screen flows, such as the
NavigationController. In your case, however, you might also consider the use of thepresentModalViewController:animated:method.It all depends really, but in general it’s better practice to make a seperate
UIViewControllerfor eachUIViewin your application.Hope this helps!