I'm new to iOS programing and to start off I am trying to create a table view in the storyboard. After creating it and linking it to the view controller as a data source, I tried to link it to ViewController.Swift but it would't allow me to put an IBOUtlet or an IBAction. I made a few new projects and tried to create the IBOutlet but it wouldn't let me do it on those either. I don't understand what's wrong, and could someone please help me fix this?
2 Answers
What method of creating IBAction/IBOutlet are you trying?
My preferred method is:
Open storyboard in editor
Select view controller in storyboard
Open assistant editor (bow tie, top right)
Check assistant editor shows view controller source (should be automatic but you may need to manually do it)
Right click control in storyboard and drag into appropriate point in assistant editor - when you let go you should get a dialogue that allows you to select an Outlet or Action.
If this isn't working can you tell us what happens or what other method you are trying?

- 4,486
- 3
- 30
- 55
-
I am trying to use this method, but when I right-click and drag into the ViewController.Swift it does allow me to insert the outlet or action from the table view. Are there any other methods I can use to link the IBOutlet and IBAction? – Cratos12 Dec 25 '14 at 14:37
-
1That is curious, it should work and suggests that something else is wrong. You say Viewcontroller.swift, have your subclassed the view controller? You need to create a sub class of ViewController of your own and then link it to the view controller in the storyboard - see this link for another SO question with a good description of how to do that: http://stackoverflow.com/questions/19370208/how-to-connect-storyboard-to-viewcontroller. – Ali Beadle Dec 25 '14 at 20:20
-
Alternatively this sounds similar to your problem: http://stackoverflow.com/questions/21247728/ios-7-cannot-connect-to-iboutlets-probably-because-im-using-uitableviewcontro – Ali Beadle Dec 25 '14 at 20:31
I also met the same issue that IBOutlet and IBAction can not be declared in the ViewController. I can share my solutions to these issues:
- Open your project Main.storyboad;
- Select the view with yellow button;
- Open Show the Identity Editor, and change the Class to your declared object.
- After the steps above, you should use Ctrl-Drag to the corresponding view controller.
In general, it should be the first step to confirm which view controller will use your IBAction and IBOutlet. Then change the Class to its your own desired class.

- 301
- 2
- 4