Copy and pasting my xib file and keeping References - xcode

So I've finished my Universal App for the Apple Store. All the code works I make all the views and references using my iPhone xib file. However, my iPad xib file is blank. So normally I would just copy and paste all the views from my iPhone xib file to the iPad file and resize each view along with its subviews, however, doing this does not copy any references. So I have to manually link each button all over again. Not a big deal, but the app I just made has like 200 buttons and I don't really want to have to link everything again. I was hoping someone here knows how to keep all the references?

I don't know how to copy and paste the view from one xib file to another while keeping all the IBOutlet and IBAction connections. But one thing you could do is go to File->Duplicate in the Xcode toolbar, and duplicate your xib file. That will create a new xib file with the same views and all of the connections intact.

Related

Where is the "Use Storyboards" button in Xcode 8.3?

In older versions, it was a "Use Storyboards" button when creating a Cocoa app that determines whether to create a storyboard file or a xib one, but now I can't find it.
Because it isn't there. It is superfluous. Just make your Cocoa project and get started. If you then want to make a xib, make one. If you want to make another storyboard, make one.
If you want to write an application that uses no storyboards at all but uses a main nib as in the old days, then make an Application xib file or a MainMenu xib file and point the target's Main Interface setting at it, and delete the default storyboard. (I just wrote an application that works that way, and it was no trouble at all. Just watch out because a modern xib has "Prefer coder" turned on by default, which may come as a surprise to an old AppKit fogie like myself.)

Is there a way to open and view the storyboard in two different windows on Xcode 7?

I'm using Xcode 7.3.1 I would like to have the same storyboard open in two side-by-side windows. I tried using the Assistant Editor to manually open the same storyboard and that works fine but when I click on one side or the other the storyboard in the other window disappears.
The reason I'm trying to do this is I want to replicate parts of the storyboard to another part and it's annoying to keep navigating all over the place and trying to remember what it looked like.
No. Storyboard is a XML file, that save changes not as often as to work with it from two screens. It can lead to mistakes. However you can temporary copy UIViewControllers and place them wherever you need, replicate parts and delete them.

Adding outlets to iPhone View

I am creating a custom iPhone View in MonoTouch through the interface builder in XCode (In monodevelop New File -> MonoTouch -> iPhone View).
When selecting a new iPhone View it creates an xib file, but no .h file is created, so how can I create outlets?
I usually drag an outlet from my label/button etc. to the .h file, but since it doesn't exist for this view, I don't know how to create the outlets.
Can someone point me in the right direction, since all articles on google are for the old versions, where outlets where created differently.
When you double-click a .xib in MonoDevelop, MonoDevelop will generate header files for your [Register]'d C# classes that subclass ObjC types and export them to a temporary Xcode project, where you can use Xcode to drag&drop Outlets and Actions.
Adding a new iPhone View file (.xib) does not auto-create any backing C# classes for you, it just creates the .xib, therefore MonoDevelop does not autogenerate any header files for you when you double-click the .xib.
When Xcode launches, you can manually create some Objective-C headers for this .xib and drag&drop outlets or actions to it (or you can create C# classes in MonoDevelop before double-clicking the .xib). When you switch back to MonoDevelop, MonoDevelop will "import" the header files, translating them into the equivalent C#.
While in Xcode, you can also add .xib's there and MonoDevelop will import those as well.
The Xamarin documentation has a good tutorial on this. There is a section for Adding Outlets and Actions to the UI using Interface Builder in Xcode4
Adding an Outlet In order to create the Outlet, use the following
procedure:
Determine for which control you want an Outlet.
Hold down the Control key on the keyboard, and then drag from the control to an empty space in your code file after the #interface
definition.

Does storyboard replace .xib file in Xcode 4.2

Have started playing with Xcode 4.2, and created a single page application using storyboard and ARC. When I opened up the file, there are five files: AppDelegate .h and .m and ViewController .h, .m and storyboard.
No .xib file.
Is this normal? Or do I need to do something to generate a .xib file?
Thank you.
This is normal. Storyboards eliminate the need for seperate .xibs. Be advised that using storyboards means you can NOT target devices running any iOS below 5.0. If this is important to you, like it is to me, then create your projects with the 'Use Storyboard' unchecked.

Not seeing my view in simulator using XCode 4.2

I have downloaded Xcode 4.2 and I'm having problems viewing my project in the simulator. I'm getting a blank whit view when I run the simulator. I'm using a single view application. I created a interface .h, .m, .xib... I have connected all actions and outlets and saved everything. My thoughts are that I have overlooked something simple. again, I just started using Xcode 4.2 today. Help!
I am assuming you are not doing this
if((self = [super initWithNibName:#"MyClass" bundle:nil])) {
// do stuff here
}
This isn't enough information to tell what's wrong with your code.
That said, if create new project in XCode using the "Single View Application" template you can see how everything is hooked up and you may be solve your problem with a 'how is mine different?' comparison.
If that fails... post some code and we might be able to see the issue.
Edit: From your screenshot it looks like you are mixing storyboards and XIBs. If you are using storyboards, then you won't see .xib files. They are inside your storyboard. You can click on the storyboard file and edit the first XIB which loads when your app runs as well as create new ones. You can still do things the "old" way by just unchecking storyboards when you first create the app. On a side note, it is possible to mix storyboards and straight XIBs, but I don't think that's what you were going for.
At a guess, you created a project with storyboards, then added a XIB manually and you get a blank XIB. Try clicking on the storyboard and modifying the XIB in there. I bet they will show up when you run your app.

Resources