This may be a very simple question, but I have grown frustrated at being unable to find the answer (maybe I am not asking the right things?) I have, of course, found the answer when using Swift, but I use Objective-C.
Basically, I am struggling with passing data between the Main.storyboard and an XIB view. The buttons to present and dismiss the XIB view, located on the Main.storyboard, work fine. However, what I want to do is allow a switch, which is present on the XIB view, to alter a few things on the Main.storyboard. I have created an outlet for the switch on the XIBView.h, but obviously, to be expected, the Main.storyboard does not recognize the outlet (it is not linked in the viewController.h for the Main.storyboard).
Basically, what I'm asking, is how to allow the Main.storyboard to be aware of the switches active state (being on or off, located on a separate XIBView)?
I appreciate any help that can be given.
I've been trying to outline the basic functionality of a swift application I was developing. I created a basic gui with the storyboard functionality that xcode provides. Here is a picture of what it looks like currently:
What I want to do next is code up a way to receive and store input from the text fields I outlined in the storyboard. Additionally I want to receive information regarding certain settings that are placed from the switches I outlined in the second screen.
I've been looking through the files that xcode provides me but I haven't been able to find the one that contains the functionality for the storyboards. If someone could point me in the right direction for that i would greatly appreciate it. Ultimately I just want to be able to manage the input provided by the interface I outlined below. Thanks!
For each view controller on the storyboard make a subclasses of UIViewController.
In the inspector panel on the left of the storyboard set the class of each view controller to their respective subclass of UIViewController.
Open up the .swift file for that view controller and storyboard and ctrl + drag from the textField to the class this will cause a small popup where you can create an IBOutlet or IBAction.
I started working with xcode a few days ago, and today I tried to connect a textview from the main storyboard to the viewcontroller, but I figured out that its not working.
I am able to ctrl+click to drag the item, but unable to place it in both viewcontroller.h and .m. I double checked that its viewcontroller and not UIViewcontroller, so this is not the case.
I'm using a Yosemite 10.10 mac.
Any kind of help would be appreciated.
Select the ViewController in storyboard and change the name of the ViewController to the name in the .h or .m file and then try ctrl+click and drag
For beginners -- > make sure you have kept the "Ctrl" key pressed down while dragging and dropping onto the code. This can be easily missed.
For me, the solution was to click on the "View" item in the dropdown menu that shows all the subviews for the controller.
Simply clicking on the controller image on the storyboard does not appear to properly "select" the controller for drag and drop abilities, the base view must be selected.
Make sure you're in Assistant Editor Mode (When code and layout editor are side-by-side).
From Apple:
With Interface Builder open in the standard editor pane, select the
control you want to configure, and click the Assistant Editor button
() in the workspace toolbar.
The assistant editor opens your object’s implementation file.
Control-drag from the control in Interface Builder to the
implementation file. (In the screenshot, the assistant editor displays
the implementation file of the view controller for the Warrior
button.) Xcode indicates where you can insert an action method in your
code.
For anyone who is new to XCode this picture might help more:
Select the item in Main.storyboard from the right pane and then set the class for the view in the right pane. Now you can ctrl + drag into your class
After trying all of the other answers, what finally fixed this issue for me is simply restarting Xcode and I was able to see the blue line that indicates where I can place my action method...
Note that dragging to any point in your code doesn't necessarily work. If you've been unable to drag to create the connection in one spot of your code, try dragging to another spot. For me, I was trying to drag to add a connection in the middle of a function which didn't work. Dragging to the beginning line of a function or in between functions did work.
Note: I'm on Xcode 9.1
Try selecting your view in the storyboard and clicking on the identity inspector on the right side in class. Enter your view controller name and then drag and drop the item from the storyboard to the view controller.
Hope it helps.
I had to both rename the class (from ViewController to ViewController2) of the ViewController.swift file and change the Custom Class (from ViewController to ViewController2) of the Main Storyboard's View Controller to make Ctrl-Drag-and-drop work again.
Renaming back to ViewController from ViewController 2 in ViewController.swift and Main Storyboard did not thwart the Ctrl-Drag-and-drop, it remained working afterward as well.
Hey I think you are not connected your storyboard viewController with your viewController class. check screen shot which "suhit" uploaded in his answer.
I would like to tell you something more than it.
When ever you need to connect any storyboard object with class.
first go to utility panel (right side) and then set class there.
after that you can connect your controls with class
I hope it will help you.
Check that the names on Viewcontroller identity inspector and the .h, .m files are the same. That worked for me
I'm using Xcode 9.2 I had my ViewControlled refactored into sections using the "extension" keyword. It appears you can't control drag into an extension of a ViewController. If you go up to the top part that is in the class definition, control dragging works fine (assuming you did the other things in this thread about making sure the right class is associated with the view controller.
I had same problem, I realised I selected wrong story board. If you made app with default settings you will get two story boards (Main and Launch Screen). Labels on Launch screen story board cannot drag drop.
Make sure that the item in question is connected to the file in which you want to control drag it to (specify the class in the identity inspector)
I'm having a weird issue that I'm really not sure what to do about. The problem is simple: In one Xcode project (both in Xcode 5 and Xcode 6 Beta 4), I see "Content" and "Prototype Cells" when I click on a UITableView in a storyboard file:
However, in another project, these are simply not appearing in an XIB file:
Does anyone have any idea how to get "Content" and "Prototype Cells" to consistently appear in both .storyboard and .xib files? Thanks!
I hope you are looking this UITableView in the Storyboard only.
When I was looking for your problem's solution I found the below observations :
When I Drag TableView over a View Controller / TableViewController to storyboard,
Then I found First screenshot in Attribute Inspector.
When I created a xib file by using File-> New-> File -> Objective C file and selected UitableViewController with interface builder.
Then I found Second screenshot in Attribute Inspector.
I hope this might help you.
Similar Issue Here - beginner here, so my wording may be incorrect (apologise in advance)
Description: When opening Main Storyboard and clicking on the TableView "view controller" icon I don't see "Content Attribute" within the "Attribute Inspector"
Issue: It looks like the actual table within the scene needs to be selected. When in Storyboard view and clicking on TableView view controller icon, this shows the attributes of the scene for TableView, which is not what you want, you want to select the actual table and not the entire TableView scene.
Resolution: I found two ways to select the actual table itself. 1.) with the TableView view controller selected, press the tab key(this cycles you though each object within a scene), until the table is selected. (the table should appear highlighted)
2.) Above the project view, I have the navigation bar, where I see the hierarchical view of my entire project. Like the following: Main.storyboard --> TableView Scene --> TableView --> etc.
Under Tableview I clicked on "Table View" and this highlighted the Table.
For me, method 1 & 2 worked and now I'm able to see the content attribute "Dynamic Prototypes" under "Table View" of the "Attributes Inspector"
I am following the tutorial here. I just created my first storyboard and tried to set it as the main storyboard. After following the tutorial I clicked the run button and the simulator doesn't render any of the changes ive created.
I have a screen shot of my xcode project here(not sure how else to display it): https://app.box.com/s/okw7jlzq5zmcetd5cehu
What am I doing wrong?
Here is another screenshot of the storyboard itself: https://app.box.com/s/jt6i0an3maowwvgsamk7
Place a checkmark in the box "Is Initial View Controller" for the view controller you want to load.
I think your problem is the code in the app delegate. When you use a storyboard, you don't need anything in there except "return YES". The storyboard creates the window, so the code you have in there is making another window, not the one that your storyboard controller is a subview of.
Using this tutorial might teach you some things about the structure of an iOS app, but if you just want to make an app with a storyboard, you should start with the "single view" template instead of the "empty" one. It will give you a storyboard and an initial controller.