views:

50

answers:

1

I have a view controller called GobanVC. It's adding a subview to do a magnification effect. That works fine, but when I call removeSuperview to get rid of it, I get an unrecognized selector error:

2010-08-26 10:10:04.014 GoGrinder[4257:207] -[GobanVC _invalidateSubviewCache]: unrecognized selector sent to instance 0x5a2f540
2010-08-26 10:10:04.016 GoGrinder[4257:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GobanVC _invalidateSubviewCache]: unrecognized selector sent to instance 0x5a2f540'

GobanVC is a UIViewController subclass, not a view, so I'm not sure why it's receiving this message. I'm adding the subview like this:

if(magnifier == nil)
{
    magnifier = [[MagnifierView alloc] initWithFrame:gobanView.bounds];
    magnifier.viewref = gobanView;
    [gobanView addSubview:magnifier];
}

gobanView is a UIView IBOutlet.

In touchesEnded I try to remove the subview like this:

if(magnifier != nil)
{
    [magnifier removeFromSuperview];
    [magnifier release];
    magnifier = nil;
}

Any ideas? It seems like _invalidateSubviewCache should be sent to the parent of the view, which is a UIView. I don't see why the VC is getting called instead.

Update:

gobanVC.view is the parent of gobanView. I added a child view using IB, and gobanView is the IBOutlet it is connected to.

A: 

Pretty interesting. I'm assuming GobanVC.view == gobanView? It seems like something convoluted is going on behind the scenes, and it'll probably take some fine combing to figure out how magnifier could possibly get a reference to GobanVC. Maybe gobanView actually contains a reference to a gobanVC?

I don't know how much code you're willing to show on here, but if you can, show as much of .m as possible so the rest of us can take a look. There are some unintuitive issues with timing in UIViewController view loading, so having all the code to look at helps a ton.

David Liu