Unable to select custom class for ViewControllers in Xcode Storyboard
Asked Answered
R

4

10

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.

Rawdin answered 29/9, 2013 at 14:10 Comment(1)
In the storyboard, make sure you are selecting the parent view controller rather than the view itself.Clustered
S
25

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.

Subtract answered 29/9, 2013 at 18:14 Comment(0)
R
11

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.

Ran answered 20/4, 2014 at 9:30 Comment(4)
don't mark this comment down! I spent a while trying to solve this very same issue and this was the only one that actually worked. I love xcode it's great!!!! :(Rotate
This ended up fixing the issue I was seeing =]Lipps
This helped med too.Lolland
Useless commentLohman
C
9

Also, make sure your view controller type (e.g. TableViewController) in your storyboard matches your view controller super class (e.g. TableViewController). Otherwise, it won't show up in the list of classes to choose from.

Chalfant answered 12/4, 2014 at 17:23 Comment(0)
S
0

For me, the problem was that my class extended a class from another framework, explicitly including the package name, eg:

class BaseMessageController: MessageKit.MessagesViewController

The fix was dropping the framework name:

class BaseMessageController: MessagesViewController

Might be an Apple bug.

Saltatory answered 7/11, 2018 at 11:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.