Take the 2-minute tour ×

I am getting the following error and I am not sure what is causing it.

2011-02-06 23:38:12.580 SApp[9648:207] -[Record superview]: unrecognized selector sent to instance 0x5f2a350
2011-02-06 23:38:12.583 SApp[9648:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Record superview]: unrecognized selector sent to instance 0x5f2a350'

Steps that are creating the error:

  • My custom class is being added to the app delegate's window.
  • My class is a subclass of UIViewController.
  • In my custom class I am adding a subview (Record) which is another subclass of UIViewController. - THIS is when the error started happening.

Code that is causing the error:

[self.view addSubview:[self.tabBarControllers objectAtIndex:0]];

I have all my .h files included where they should be, so I am not sure what is causing this. And ideas?

share|improve this question

1 Answer 1

up vote 11 down vote accepted

You cannot add a UIViewController (Record) as a subview of another view. Instead, add the view managed by that view controller as a subview.

UIViewController *recordController = [self.tabBarControllers objectAtIndex:0];

[self.view addSubview:recordController.view];
share|improve this answer
Ha, thank you! It seems so obvious now that you point this out. :) –  Nic Hubbard Feb 7 '11 at 17:24
What @NicHubbard said –  Cyprus106 Apr 30 at 22:18

Your Answer


