Note that there are some explanatory texts on larger screens.

plurals
  1. POInterfaceBuilder - UIViewController subclass not recognized as subclass
    text
    copied!<p>I'm working on a simple iPhone app.</p> <p>I have 1 UINavigationController and 2 subclasses of UIViewController.</p> <p>I have a MainWindow.xib file, a PersonListView.xib, and a PersonDetailView.xib.</p> <p>The MainWindow.xib has the UINavigationController with the view linked over to the PersonListView.xib file.</p> <p>The PersonListView.xib has the File's Owner listed as a PersonListViewController class.</p> <p>I have some buttons on the PersonListView, along with labels and images. All displays correctly.</p> <p>When I try to link a button on the PersonListView to my PersonListViewController class, the button is not firing....</p> <p>The result: <strong>* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*</strong> -[UIViewController viewDetail]: unrecognized selector sent to instance 0x450d50'</p> <p>If I go into the debug console and print-object 0x450d50, I get:</p> <p>(gdb) print-object 0x450d50 (gdb) </p> <p>The Interface Builder correctly shows the File's Owner as a PersonListViewController, so why would my button action (linked to the File's Owner) go to the superclass somehow?</p> <p>EDIT1: Ok, what seems to be happening is that I wasn't getting an instance of the subclass unless, in my MainWindow.xib, I explicitly set the class of the view controller to my subclass.</p> <p>There's still got to be something I'm missing, though, because surely I should be able to start up arbitrary subclasses of UIViewController just by swapping out the NIB file name from the main window?</p> <p>EDIT2: (Response to Kevin) That's not what I'm saying regarding the contents of a XIB. </p> <p>I have 3 XIBs:</p> <p>MainWindow PeopleListView PeopleDetailView</p> <p>The PeopleListView and PeopleDetailView each have an associated File's Owner that is a corresponding UIViewController subclass. Obviously, I need my events to go to the right controller classes as I move from page to page...but if I can only use a default UIViewController or one subclass, that will be much more difficult?</p> <p>I can get the correct effect in code by manually setting up the UINavigationController with the correct root, but I feel like there should be a better way through InterfaceBuilder.</p> <p>EDIT3: (to Kendall) I'm not using a tab bar. The model is the same, though, that the view in my navigation controller has to be wired to a single subclass, which seems a bit icky.</p> <p>EDIT4: (to lostintransit) The PersonListViewController has the appropriate - (IBAction) viewDetail; method. The problem is that I can't find a way, in my MainWindow.xib, to flag the view inside my UINavigationController as "initially load this from PersonListView.xib, with a PersonListViewController as the view" that wouldn't make it difficult to replace the PersonListView with a PersonDetailView.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload