Making superview's controller respond to events

Nibbie
Posts: 3
Joined: 2009.12
Post: #1
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?
Quote this message in a reply
⌘-R in Chief
Posts: 1,247
Joined: 2002.05
Post: #2
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.
Quote this message in a reply
Nibbie
Posts: 3
Joined: 2009.12
Post: #3
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!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  re-init a view controller...from within aerospaceman 8 4,256 Jun 30, 2009 07:24 PM
Last Post: aerospaceman
  UIScrollView won't bounce, and doesn't respond to touches consistently. groffhibbitz 0 3,254 Jun 3, 2009 11:30 AM
Last Post: groffhibbitz
  Model-View-Controller and touch events Vinnie 3 3,545 Jun 3, 2009 09:27 AM
Last Post: AnotherJake