Object library changes using XCode 4 and storyboard - iphone

When working in the .h or .m of my iPhone app in XCode, the Object Library contains a lot of nice buttons and stuff, i.e. a checkbox, which I would like to add to the interface. But when I enter the storyboard, it changes to just "Objects" and many of the buttons are replaced with view controllers and other stuff. How can I find the Object Library with all the buttons in my storyboard? I wanna add some checkboxes etc in my app. Thanks.

See when you are working in .h and .m the object library shows all the stuff of iPhone/iPad and Mac.but when you open storyboard for iPhone/iPad all the stuff regarding Mac development is gone ,only the stuff relevant to iPhone/iPad is shown.

Related

Merging single view app to a storyboard

This is my first application with multiple views.
I have an app that uses a storybord (main app), and another app with a single viewController and a nib file.
I would like to merge the singleView app as part of the main app.
Is there a way to do it?
How do I add the nib, and attach it to its viewController?
*Also please state if it's something that is really not recommended to do or not.
Please let me know if any more info needed.
You could simply copy whole view controller from the xib of the "single nib" project to a storyboard project.
Select "View Controller" in the xib of the single nib project as shown in image below and press cmd+c.
Open storyboard and press cmd+v. Your view controller from xib should be copied as shown in image below.
Now you should copy ViewController.m and ViewController.h (or whatever they are called) files from the single nib project.
Open Finder, find those files and drag them to the storyboard project in Xcode (somewhere in the project navigator). Be sure to select items shown in following image when copy dialog is prompted.
Now you should reconnect outlets and actions to copied view controller .h (cmd + drag from storyboard to .h file - you should already be familiar with this process)
And now you build to see if everything is working.
You should be able to just copy your existing single view nibs content into your story board. Just open both projects and copy-paste.
HOWEVER: I usually opt against storyboards. Especially when you're working in a team, they really mess things up (because of their single file/monolithic nature). I'd rather suggest you work on different files for each screen and tie them together with code.
While this may not be a concern for you, it may well be one later on.

Link IBOutlet to both iPhone and iPad Storyboards

I am writing a universal application. As far as I can tell, it's not possible to use Interface Builder to link an IBOutlet, which is already linked to the iPhone storyboard, to the iPad storyboard?
What are possible workarounds for this? Should I just edit the storyboard via text editor?
It doesn't really seem sensible to have an IBOutlet for each device if it's the exact same element behaving in the exact same fashion.
Cheers-
You should be perfectly capable and able to add IBOutlet's to both an iPhone_Storyboard file and likewise the same IBOutlet's on an iPad_Storyboard file. What does it appear to be doing, simply detaching your previous connection in the other Storyboard file?
I've done this on multiple universal applications without an issue.
I ran into this issue as well. My problem was that I forgot to make sure that the Custom Class of the UIView were the same in both the iPhone and iPad versions of the storyboard. After fixing that, Xcode instantly let me connect the outlets.

Can't Connect iPad Outlets?

I'm creating an iPad version of an iPhone app (NOT universal). I created copies of all my .m .h and XIB files, and appended "iPad" to the end of each, as well as to all my classes. This of course was tedious and overly complex but I didn't know a better way.
My problem: When I connect the iPad File's Owner and First Responder to my iPad XIB (see image) Xcode connects the XIB shown below to the iPhone ViewController code and not the iPad ViewController code.
I then went to the code (see below) to see if I could instead connect straight from the code (with those little circles to the left of Outlet code lines) but to no avail. When I click and drag the line and let go over the XIB it doesn't work. It doesn't do anything.
How do I associate (for lack of a better word) my iPad XIB with my iPad code? The iPad XIB is already part of the target build, FWIW.
Click on FileOwner in iPad xib file..
Go to identity inspector..in the Utilities Section.
You will see the class name there..Make sure it points to the iPad code class
Make sure that you've included the correct File name in your XIB in the File Inspector. This should match the class you are trying to connect objects.
Check the class you given for each xib is correct .that is in the identity inspector
Try this
File->Reload All Class Files
File->Read Class Files (select MyClass.h)
Reconnect File's Owner by
a. Setting the Class to "MyClass"
b. Reconnecting the View to the File's Owner's View
Everything is back to normal now. Weird.
Hope this helps more than it confuses ;-)

MKMapview in tabbed application in xcode 4.2

I am a beginner in iOS development and have just start using the lasted xcode 4.2. I am developing an application using the storyboard having a tabbed interface. The application will have four tabs among which one should incorporate a Mapview. After setting the four tabs and linking them all together, i added a mapview to my first tab but i cant edit the Mapview properties or even add annotations since when adding the Mapview, it does not come with any .h or .m file. Any help concerning this would be greatly helpful.
You need to create classes (.h/.m) for your UIViewController's and link the interface elements in the storyboard to the underlying classes. Then within your UIViewController implementations, you can link your interface MKMapView to your class properties, then you can manipulate the MKMapView instance any way you want programatically through your UIViewController implementing class.
See here for a tutorial on usage of the storyboard.

Connecting outlets in Window Based App, Objective-C

I'm reading through a beginners iPhone text book and just finished writing all the code for a route tracker app that uses Map Kit and Core Location. I have the app running with no errors on my iphone 4 device but when I tried interacting I realized that none of my IBOutlets were connected to anything. When I referenced the beginning of the tutorial in the text, all it says is to "connect the appropriate outlets".
Here's why this usually simple task has me confused. The tutorial says to create a Window Based Project, so there is no ViewController. Then, in Interface Builder, the view is built in MainWindow.xib. The only IBOutlets of the project are located in Controller.h / Controller.m files that you create and which contain mostly all of the code for the app.
I usually ctrl-drag from File's Owner to the UI in Interface Builder, but in this project there seems to be no way for me to access the IBOutlets in Controller.h / .m from the MainWindow.xib file.
I'm frustrated because it seems like this should be such an easy fix but I'm totally stumped.. any help is really appreciated. Thanks
As I see it, you have two choices:
Add the outlets to the app delegate. This is probably not the best plan.
Put an instance of your controller class in the .xib file.
I think option 2 is what you want. If you check the Controllers section of the library, you'll see a component called "Object". Drag one of those into your xib, then inspect it. Select the info pane in the inspector (the circle with a white i in it) and change the Class to the name of your controller class.