Xib view controller in storyboard - ios

I'm trying to use this repository from Github and to use it you must have a xib file whether it's in your storyboard or not and I wanted to know how I can do to have my view controllers acting like xib but in my storyboard.
I'm sorry if I'm not clear enough but just tell me in the comments and I'll try my best to be clearer.
Kindest regards,

All you have to do is in your project select New File from the file menu or by right clicking in your file navigator. On the popupWindow select iOS on the left (This will let you see all the options) find the "View Option".
and this will create a View.Xib file. This is just the UI file for a view.

Related

Merge storyboards together in Xcode

I have a start.storyboard file that contains two basic view controllers. I also have my main.storyboard file that contains a tab bar view controller. While I see the benefit of using storyboard references, my question is if I can go the other way. Can I combine the start.storyboard and main.storyboard files, much like how I can go the other way with Refactor to Storyboard. I have included a screenshot of each storyboard below.
Per Pierre Perrin: "The easiest way is to select your viewControllers, copy and paste in you main.storyboard." Regarding the swift files associated with the view controllers and whether or not you will need to update the class references in the identity inspector, "normally it will be done automatically. The segues are related with the viewController and not with the Storyboard."

Can't drag and drop item from storyboard to viewcontroller in xcode

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)

Generate storyboard ios

I want to do a slid-out menu in my app, but the problem is I dont find my storyboard in the project, there is a way to generated from the xib file ? or a new empty storyboard can do the job ?
You better use a .xib instead of a storyboard for side menu.
See this GIT repo for side menu - recomend
https://github.com/mikefrederick/MFSideMenu

How to copy and paste Xib file with xCode Interface Builder

I need to create a new xib file and want to use an existing xib to base my layout off of. What's the best way to create the new xib file? If it was Android I'd copy and paste the xml and then start tweaking but with the IB I don't have that option (right?).
I've tried two things so far, (1) copying and pasting the file in xCode but the option isn't there and (2) copying all the UI elements from the old xib and pasting them into a new blank xib. This copies all the UI objects, but doesn't maintain structure or spacing at all. What's the best way?
Just make a copy of NIB file, rename it and add to the same Xcode project. Change File Owner class in new nib if needed.
When I need to do this I convert the file to a .nib (shift click the file and delete .xib and add .nib) then you can see all the XML copy that. Then I make a new .xib and convert that to .nib and paste the XML then you can convert them both back to a .xib. You can also Right click the file and navigate to View As > Source Code
If Storyboard is used: Add a new UIViewController to the storyboard. Remove its main view so that the view controller is empty. Set the Class of the view controller (in the Identity Inspector) to that of your nib's File's Owner. Also make sure the .h and .m files are added to your project already.
Now open the nib, select the top-most view and press Cmd-C to copy it to the clipboard. Switch to the storyboard, select that new, empty view controller. Press Cmd-V to paste the contents of the nib into this view controller.
You may have to reconnect all the outlets and actions, but at least you don't have to do the layout again.

Example of iPad SplitView where there is an .xib file specified for Root Controller?

Is it possible to specify a xib file for the RootController of an iPad's splitview?
Open the MainWindow-iPad.xib that is autogenerated with your project. You should be able to expand the SplitViewController to display the viewControllers that are housed in it. You'll notice that the Detail side says something about "Loaded by DetailViewController.xib". You'll have to click the RootViewController icon and specify a nib name and make the necessary connections in Interface Builder.
I'm sure you found an answer already, but for folks who are reading this and want a good source, the Apple Sample COde "MultipleDetailView" uses a SplitView that goes to new nibs for the RootController...just use that as a guide!

Resources