Unable to select custom class for ViewControllers in Xcode Storyboard

I just upgraded Xcode to 5.0. I'm still pretty new to cocoa, so hopefully I'll miss something basic. Basically, I can't get Xcode to see user classes that I want to use as parent classes for view controllers. Initially, I wanted to create a custom class for the table controller, but to simplify the problem, I tried it with the usual view controllers, but this also does not work.

What am I doing:

  • Create New Project: One-View Application
  • Add to it the cocoa class (class File-> New-> File → Objective-C. I call 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 in a custom class

The class simply does not appear in the drop-down list, and I cannot print it either. Many other threats reporting the same problem suggest closing / reopening the project and Xcode, but this does not work for me.

+6
source share
3 answers

When you are in the storyboard, Interface Builder Xcode, make sure you click on the black 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. After that, you can set the view controller class in the Identity Inspector.

+14
source

I finally decided. You must save your work and exit xcode. But look close , you should exit xcode.

When you start xcode again, you will see your created viewcontroller.

+6
source

Also, make sure that your type of view controller (e.g., TableViewController) in your storyboard matches the superclass of the view controller (e.g. TableViewController). Otherwise, it will not appear in the list of classes to choose from.

+5
source

Source: https://habr.com/ru/post/954886/


All Articles