Question

I have a managing view controller that switches in one of a set of previously allocated sub view controllers when the user chooses a menu item.

When I switch in a view controller I hook up the view of the managing view controller to the view in the sub view controller.

[mvc.view addSubview:subvc.view];

It all seems to work fine.

However, when removing that sub view controller's view from the view hierarchy with (eg.. when switching pages in the application):

[subvc.view removeFromSuperview];

  • the willRemoveSubview method in the custom view class never fires. I've confirmed that when I make the removeFromSuperview call I am calling it on an instance of my custom view class.

Other methods in my custom view class do fire though, such as viewWillMoveToWindow.

The NSView reference doc says this method should be called?

Can anyone suggest why this isn't working?

I'm running on 10.8.2 compiling for 10.7 with Xcode 4.5.2

Thanks

Darren.

Was it helpful?

Solution

willRemoveSubview:, as the name suggests, is called on the super view, not the subview being removed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top