Making superview's controller respond to events
I have a ViewController A with pointers to several other ViewControllers.
From A's own view, I there's a button that adds ViewController B's view to the subview. From this view, there's another button that takes me back to ViewController A's view.
However, how would I go about if I want ViewController A to react to its appearance? For example, I might want to animate stuff to A's view when B's view was removed from the superview.
I could solve this by setting a pointer in B to A, but I don't want to create circular dependencies. Is there an easy way to solve this?
From A's own view, I there's a button that adds ViewController B's view to the subview. From this view, there's another button that takes me back to ViewController A's view.
However, how would I go about if I want ViewController A to react to its appearance? For example, I might want to animate stuff to A's view when B's view was removed from the superview.
I could solve this by setting a pointer in B to A, but I don't want to create circular dependencies. Is there an easy way to solve this?
Without guessing too much about what you're really wanting to do, perhaps you're looking for UIView's - (void)willRemoveSubview:(UIView *)subview method? Use that in A's view to know when B is being removed and then do the animation?
But otherwise, circular references are common. As long as the reference from B to A is weak, then you won't have any memory trouble.
But otherwise, circular references are common. As long as the reference from B to A is weak, then you won't have any memory trouble.
FreakSoftware Wrote:Without guessing too much about what you're really wanting to do, perhaps you're looking for UIView's - (void)willRemoveSubview:(UIView *)subview method? Use that in A's view to know when B is being removed and then do the animation?
But otherwise, circular references are common. As long as the reference from B to A is weak, then you won't have any memory trouble.
Thanks for the quick reply, however, I already solved the problem by using NSNotificationCenter that posts a notification which the MainViewController listens to. Works like a charm!
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| re-init a view controller...from within | aerospaceman | 8 | 3,727 |
Jun 30, 2009 07:24 PM Last Post: aerospaceman |
|
| UIScrollView won't bounce, and doesn't respond to touches consistently. | groffhibbitz | 0 | 2,921 |
Jun 3, 2009 11:30 AM Last Post: groffhibbitz |
|
| Model-View-Controller and touch events | Vinnie | 3 | 3,253 |
Jun 3, 2009 09:27 AM Last Post: AnotherJake |
|

