Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to select custom class for ViewControllers in Xcode Storyboard

I just upgraded Xcode to 5.0. I'm still fairly new to cocoa so I hope I'm overlooking something basic. Basically I can't get Xcode to see the custom classes that I want to use as parent classes for view controllers. Originally I wanted to create a custom class for a tableview controller but to simplify the problem I tried it with regular viewcontrollers, but that doesnt work either.

What I do:

  • Create new project: Single View Application
  • Add a cocoa class to it (File->New->File->Objective-C class. I name it MyViewController and make it a subclass of UIViewController
  • I select the default view that comes with the project template in the storyboard, and in the Identity inspector I try to select MyViewController under Custom Class

The class simply does not appear in the drop down, and I cant type it myself either. Many other threats reporting the same problem suggest closing/reopening the project and Xcode but that doesnt work either for me.

like image 580
garma Avatar asked Sep 29 '13 14:09

garma


2 Answers

I finally solved it. You must save your work and quit xcode. But look don't close, you have to quit xcode.

When you run xcode again, you will see your viewcontroller that you just created.

like image 58
kordiseps Avatar answered Jan 22 '23 04:01

kordiseps


When you are in the storyboard, Interface Builder of Xcode, make sure you click on black colored bar under the view:

enter image description here

This will select the view controller (not the view) in the storyboard. Notice how the whole scene has a blue border around it. Once this is selected, you can set the class of the view controller in the Identity Inspector.

like image 20
wigging Avatar answered Jan 22 '23 04:01

wigging