So I have my app set up with two view controllers. The first one is my initiation screen, where the app starts, and the second is one the user can navigate to. I added the second one later on in my development, but when I went to the right column under the identity inspector, my new Cocoa Touch Class file is not populated for me to select. Now if you ask me to just type it in, I've tried that, it does not seem to connect. I've tested it by printing a simple line in the viewDidLoad() of the new second class when it is loaded in the simulator, but nothing is printed. Any help would be greatly appreciated!! Thanks!
Asked
Active
Viewed 1,854 times
1
-
Looks like the class isn't a subclass of `UIViewController`. – brandonscript Jan 30 '17 at 04:39
-
Here is a similar Stack Overflow question with many answers: [Storyboard uiviewcontroller, 'custom class' not showing in drop down](http://stackoverflow.com/questions/14130184/storyboard-uiviewcontroller-custom-class-not-showing-in-drop-down) – Mobile Dan Jan 30 '17 at 05:21
-
@MobileDan none of the solutions there worked for me – user3794832 Jan 30 '17 at 05:25
-
If you were to put "let _ = SecondViewController()" in one of the AppDelegate methods, does it compile? I just want to confirm that the compiler sees the SecondViewController class. – Mobile Dan Jan 30 '17 at 05:31
-
I assume you tried this but I just want to throw out common fixes to strange issues like doing a deep project clean and closing and reopening Xcode. – Mobile Dan Jan 30 '17 at 05:33
-
@MobileDan yup, it recognizes it -- just don't know why its not linking together. is there more code/screenshots you need? – user3794832 Jan 30 '17 at 05:38
-
You could add a screen shot of SecondViewController selected within Interface Builder. – Mobile Dan Jan 30 '17 at 05:57
-
One other thing to confirm is that the "Class" dropdown box where you expect to see SecondViewController as an option displays "UIViewController" when no text is entered into it. – Mobile Dan Jan 30 '17 at 06:00
-
Yes it does @ the UIViewController comment, and it's just empty for now -- i just want to link it before i do any work on it – user3794832 Jan 30 '17 at 06:11
2 Answers
2
Easy fix is:
- Select the activity indicator on storyboard and go to identity inspector and copy the object id. as image: ObjectID_ActivityIndicator
- Right click the storyboard file which has the view controller you are working at.
- Open as > Source Code
- Press command + F to find and look for the id you copied previously
- Paste this: customClass="yourclassname" customModule="moduleNAme" customModuleProvider="target"(don't change this target word, you can choose desired module from identity inspector if any).
- Command + S to save it and again right click on storyboard file > openAs> Interface builder
- Now select activity indicator again and go to identity inspector. You will now see it there. You can also change it as per requirement.
Enjoy. I faced this problem today and found no help online. My class and module field were greyed out. Tried this fix and it worked.
Note: Make sure your custom class is accessible and is in app directory i.e it's not highlighted in red color but gives a normal look.

Zohaib Ejaz
- 387
- 4
- 18
1
I have seen a problem like this where the solution was to change the "Module" to a specific value, close the storyboard, reopen it and delete the "Module" setting (assuming it was originally blank or restore it to its original value). This happened in project with many targets and their names may have changed.

Mobile Dan
- 6,444
- 1
- 44
- 44
-
How is this an answer to a question that gave little code? (That's why I down-voted. And I'll remove it if I'm wrong.) Please ask for more details - the question wasn't close to being of acceptable quality. – Jan 30 '17 at 04:55
-
Thanks for your comment @dfd. I was just going to ask why this was downvoted since it is a legitimate possibility and solution. You answered my question though. I agree that the question is/was vague at the time I wrote my answer. However, it reminded me of the situation I described because it was so frustrating. – Mobile Dan Jan 30 '17 at 04:59
-
1My bad. I'm apparently having a bad night. Low quality questions (which this one clearly is) do not equate to down voting somebody trying to help. – Jan 30 '17 at 05:08
-
@MobileDan & dfd what other info do you guys need? I'm new to stack overflow, so i apologize in advance for my naiveness – user3794832 Jan 30 '17 at 05:15