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.)
Related
I have a cocos2d-x application that I have been mostly debugging on iOS. Now I am working on the OS X side of things.
As expected, everything works pretty much the same, except that I have some gesture commands in my iOS app that do not translate to OS X.
I would like to create menu items (OS X level) and associated shortcuts to accomplish some of the gesture interactions (at least as one option).
Creating a MainMenu.xib and linking it in the project settings doesn't seem to be the whole story. The menus are still the generic "AppName" and Window menus, and not the ones I created in the xib file.
I believe I need to wire it up to the AppDelegate somehow, but I'm not sure how, and I haven't had any success finding documentation to that effect, at least in relation to how it interplays with Cocos2d-x.
Essentially you just need to create the menu in an Objective-C++ class that you call from AppDelegate.cpp or wherever. The extension will be .mm in order to invoke the objective-c compiler/runtime. You can then create the NSMenu and add items or replace an entire menu set[ServiceMenu/WindowMenu/MainMenu]
NSMenu reference: https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSMenu_Class/index.html)
I found the only interesting part was receiving an action from the menu where I believe you need to then also create an objective-c class as the receiver (target).
You should be able to load the .xib file in as a entirely new menu to replace the one GLFW3 creates, but I haven't looked into that yet.
Update: Here's an example project.
https://github.com/stevetranby/TestNSMenuCocos2Dx
Update: Added example to project for loading the menu with .xib
I often make use of views in interface builder that live outside of the viewcontroller hierarchy (see screen grab below for simple example).
Before upgrading to Xcode5 I could get this view to appear on the storyboard by writing an IBAction outlet and dragging a connection from the code to the view in the storyboard.
If you paused over the button for a moment it would flash and then open up as a view on the storyboard that is then a lot easier to work with.
Since upgrading this function no longer seems available. Has anyone found out how to get these views to appear on the storyboard?
Edit:
Using the temporary viewcontroller as described in this answer seems one approach, although fiddly since you need to move the UIView stack between viewcontrollers each time you want to edit the layout. Using a separate XIB is starting to seem like the sanest approach.
https://stackoverflow.com/a/13713385/1060154
Finally, we get this back in Xcode 7.
Hallelu!
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.
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.
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.