views:

26

answers:

3

I have a MasterViewController.h.m.xib (UIViewController) that is opening a TestDummy.h.m.xib (UIViewController) in the following way:

TestDummy *controller = [[TestDummy alloc] initWithNibName:@"TestDummy" bundle:nil];
[scrollView addSubview:controller.view];

I have two buttons in TestDummy: (Open), (Close) and one label: (windowDepth).

I'm trying to create a second instance TestDummy that is open by the first TestDummy. Then allow multiple TestDummy (UIViewController) to open to N depth and allow the close button to take them back to zero depth. Here's what i have for my Open button.

-(IBAction) btnOpen_Clicked{
TestDummy *newController = [[TestDummy alloc] initWithNibName:@"TestDummy" bundle:nil];
newController.isNotRoot = YES;
newController.windowDepth = self.windowDepth + 1;
//do stuff...
childDummy = newController;

// start the animated transition
[UIView beginAnimations:@"page transition" context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];

//insert your new subview
[self.view addSubview:newController.view];

// commit the transition animation
[UIView commitAnimations];
[newController release];

}

When i do this i get an error in the debug console.

2010-10-07 00:59:12.549 OrionClient[5821:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType btnOpen_Clicked]: unrecognized selector sent to instance 0x6a339a0'

Must be a memory management issue but i can't figure it out.

Thanks in advance.

A: 

'NSInvalidArgumentException', reason: '-[__NSCFType btnOpen_Clicked]: unrecognized selector sent to instance 0x6a339a0'

It means you are trying to call a non existing method on that instance. How have you defined the btnOpen_Clicked selector? I'm guessing it should look more like, but really need to see how you defined the selector.

-(IBAction) btnOpen_Clicked:(id)sender
willcodejavaforfood
A: 

It means that the application can't find your method btnOpen_Clicked.

First rename your method with :

-(IBAction) btnOpen_Clicked:(id)sender

Then make sure this method specification is in the .h file And in InterfaceBuilder with your TestDummy.xib, make also sure that the link between the button and this method is correctly done with for example TouchUpInside event.

William Remacle
A: 

solved it removed the last line [newController release]; need to figure out where to actually call this correctly though.

Ducksauce