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.
Related
I don't know the reason, but Xcode from today won't open .xib and .storyboard files as visual editor, but only as XML.
If I right click on one of these file, trying to choose "Open as..." this is the result. Very strange.
Load the corresponding view controller source in the assistant editor, the main editor switched to the IB view. From then on, all storyboards and Xib loaded as IB views.
Select storyboard > Editor > Assistant
All storyboards loaded as IB views.
Not sure it's feature or bug in Xcode.
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.)
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 try to transfer an existing cocoa application to make use of the new storyboards for OS X with XCode6 (Beta2).
I added a new blank storyboard file and set it as the main interface of my application.
However, I have no idea how to link my NSApplication to this storyboard.
When I start a new project using storyboards I see a scene called application scene. It includes the Application (NSApplication object), Main Menu, AppDelegate...
How can I add an application object (i.e. an application scene) to a blank storyboard?
Is there something analogous to window controller and view controller objects which can be dragged on the storyboard?
As a quicker alternative, you could copy the Application Scene from a new project to your existing one:
Create a new, empty project with the "Use storyboards" option enabled.
In the new project, option-click the storyboard file, select "Open with External Editor".
In your favorite text editor, select the Scene node right under "<!--Application-->" and copy it to clipboard.
In the project that has a missing Application Scene, repeat step 2.
Paste the scene node you just copied at the top of the Scenes node (mind the plural!).
Save.
You'll now have an Application Scene in your existing project, which saves a lot of time compared to copying everything over to a new project.
Some people at the Apple Developer Forum seem to have the same problem as well:
Mac Storyboard and Application Menus
It seems that currently there is no out-of-the-box way of migrating an existing application to use storyboards. That's true at least for XCode6 Beta2.
I ended up creating a new project and transferring my existing code base manually.
A possible way is just to copy and paste the objects from a fresh project that had "Use storyboards" checked during creation within XCode.
I am c# asp.net developer and just a newbe in developing ios apps. I am trying some tutorials to build some uipickerview. But the most tutorials are using an xib file. My project is a storyboard project and dont have a xib file. So Iam wondering how I can connect my datasource and delegate from my uipickerview? In some toturials I see the "view controller scene" window in xcode, but I cannot find it in my xcode. So can somebody tell me what to do to show this "view controller scene" OR how to connect my uipickerview to the datasource and delegate?
The Storyboard is replacing the xib files and combines all your views into a single file for iPhone or iPad. To connect a picker view data source and delegate you can select the UIPickerView object in Interface Builder, go to the Connections Inspector (the menu with the arrow icon on the right) and there drag from the datasource to the view controller file owner.
Do the same for the delegate.
Then in the header file of that view controller you need to add the UIPickerViewDataSource and UIPickerViewDelegate protocols to the interface and in the implementation file implement the relevant methods.
Drag the delegates to the files owner in interface builder, you dont need a interface