pdenlinger
pdenlinger

Reputation: 3917

Why won't new class show up in Identity Inspector/Custom Class in Interface Builder?

I'm having a repeating problem in Xcode 4.5 and would like to ask for help/advice.

Have been creating a new class, BIDSwitchViewController, which is a subclass of UIViewController. When I go to the Identity Inspector to layout the .xib file, of course I want to change the class it belongs to to BIDSwitchViewController, so that I can layout my objects and make my connections.

But BIDSwitchViewController doesn't show up in the dropdown list for Custom Class in Identity Inspector. So then I hardcode "BIDSwitchViewController" into the text box, but then that doesn't stick.

What am I doing wrong,and what can I do to fix this?

Thanks in advance.

Upvotes: 13

Views: 8753

Answers (8)

ctvr
ctvr

Reputation: 21

If the custom class in question is not a subclass of the type of class you want to associate it, it wont auto populate in Identity Inspector. That is, for view controllers the custom class should be UIViewController. For table view cells it should be a subclass of UITableViewCell.

Upvotes: 0

mercury
mercury

Reputation: 2755

After two days of frustrations and deleting the project then the Xcode itself , i did not find any solution until i remembered the inheritance of my viewController , it was a viewController for a table storyboard view, but it does inherit from a UIViewController not a UITableViewController . just when i corrected , it show up .

Just make sure that your view has the right inheritance class as the same storyboard view .

class AddItemViewController: UITableViewController

Upvotes: 2

eemmrrkk
eemmrrkk

Reputation: 1700

SpecialViewController.h and SpecialViewController.m may be looking as a C - file and C - header file.

I tried , right click on SpecialViewController.h then Show File Inspector.

Then switched the Type to Objective-C source from the C-source , then it worked for me.

Upvotes: 0

Sakiboy
Sakiboy

Reputation: 7459

If restarting doesn't fix it...

  1. Click on a different file
  2. then go back to your .Storyboard or .XIB.

...Or try and open up your .Storyboard or .XIB in a new tab. Basically you just want to force the IB to reload and re-render.

Upvotes: 3

golangphp
golangphp

Reputation: 115

Make sure you have selected "File Owner" in Placeholder before selecting the class.

Upvotes: 1

physicsfrac
physicsfrac

Reputation: 37

I have been struggling with this same problem as well and as Chanson Yan said click on table view or any view, then click on the main view controller (File's Owner) then check the drop-down menu again and it should appear.

Upvotes: 0

sunkehappy
sunkehappy

Reputation: 9101

My way to solve this problem is to restart my Xcode! Then all works fine. Just have a try!

Upvotes: 11

ChansonYan
ChansonYan

Reputation: 11

It is the problem of Xcode, you should switch between selecting table view and table view controller (File's owner in your practice), and the new added file names will pop out in the drop down list. I have tried, and it's done.

Upvotes: 1

Related Questions