I thought I was fairly experienced at iPhone development, but I'm tripping up on the Stanford iPhone course on the very first video.
(38 mins in)
The teacher, drags an NSObject into the MainWindow.xib. And when he inspects the Object in the Identity Inspector (Cmd-4), there are Class Actions and Class Outlets sections.
However, these don't appear for me, just Class Identity and Interface Builder Identity... Where have they gone?
Interface Builder has gone through some changes recently. Go to classes in the library panel, select the object from the top half you wish to inspect and the lower half of the screen has tabs for Lineage, Definitions, Outlets and Actions.
In the library panel find the Segmented-Button, Click on classes. Find NSObject or any other class you would like to subclass. Right click and "New subclass...", Name it something useful in the pop up like controller/AppController. Find your newly named Class in the class list. Now add all your actions/outlets in the Bottom of the library panel.
Thanks to Convolution I would never have found this. (Just thought I'd expand on the above tip).
I finally solve my issue as the same as you. Before , I used a earlier version of IB, that's 3.1. And I can access "Class Actions and Class Outlets sections" on Tools-> Identity Inspector Panel. But after I choose another macbook (which IB is upgraded to version 3.2.1), I must access the corresponding section Library panel->Classes Tab->choose the specified object, then go to the panel's lower part(as illustrated by Convolution).
Related
I am using Interface Builder and Storyboards to build my app. I am trying to connect my source code to my UIViewController in Storyboard, but none of my classes show up in the Custom Class dropdown menu. This is occurring in Xcode 11 beta 2 and Xcode 11 beta 4.
I've tried some solutions in this Stack Overflow answer, but they are not working. I've already done all of the following:
Relaunched Xcode
Deleted derived data
Reinstalled Xcode
Tried a different Storyboard
Recreated the UIViewController file
Made a new project (the problem even occurred there)
Typing the UIViewController name into the dropdown menu text field
None of the solutions worked and I have made sure that I was connected a UIViewController to the Storyboard not something else like a UIView. This is occurring with all of my UIViewControllers and UITableViewControllers.
(I wish I could show an image but I do not have enough reputation...)
I expected the UIViewControllers that I have created to appear in the custom class dropdown. I also surprised to find out that manually typing the view controller into the text field does not work. Instead, when I run the project, I just get this message in the console:
Unknown class ViewControllerName in Interface Builder file.
It appears that your classes aren't added to the project target. Try this:
1) Make sure your classes are added to the right target membership on the Inspectors Panel on the right:
2) Make sure the class inherits the View Controller type:
class CustomViewController: UIViewController
3) Reload xCode and check if the class is enabled:
It happened to me and I've noticed the Class dropdown was showing classes from another project that I have opened in the background. After closing all the other projects, the drop down finally showing the correct list of classes from the project that I'm working on. Seems like an Xcode storyboard editor bug.
I'm writing my first iPhone app. I needed a custom switch (I want it to say "Male/Female" rather than "On/Off"), and I found RCSwitch but I'm having trouble figuring out how to integrate a downloaded widget into my project. I assume this is a fairly common thing to do, but I can't seem to find any documentation online on how to use a downloaded widget / class.
I have succeeded in adding the code in via Build Phases -> Link Binary with Libraries. An RCSwitch directory appears within my project tree, and if I do a diff I see that it has added code related to RCSwitch to the header files.
The problem is getting the widget onto the .storyboard image. The RCSwitch widget itself does not appear in the "Objects" box -- the one that is by default at the lower right of the screen and includes images of the widgets that you can drag into the storyboard. Perhaps I'm missing something?
from the xcode 4 transition guide (pg. 65):
Drag a custom view object from the library into the nib file.
After adding the custom view to your nib, select the custom view and
assign the correct class to it in the class field under Custom Class
in the Identity inspector
Some more resources:
iphone-creating-custom-objects-for-interface-builder
Interface Builder Help - Custom Object
In Xcode 3 one used to be able to define Outlets, Actions etc in Interface Builder by going to the Library > Classes Pane and selecting the class from the list. Is this functionality missing in Xcode 4 ?
There is a File Template Library in the Utility area (Lower Right Corner) in Xcode 4 but my custom clases do not show here !!
This does appear to be removed from Xcode 4, but there isn't much need for it anymore since Xcode 4 integrates the editor directly with IB. The feature never really worked that well in Xcode 3 IMO anyway.
In Xcode 4, display the header for your object by selecting your object and View>Editors>Assistant. Now control-drag from the object you want to connect into the header. This will let you automatically create an outlet or action and bind it all at once.
See the Xcode 4 Transition Guide for more information.
agreed with Rob on that, alternative is to right click your Object in xcode's IB and this will give allow you to select actions/reference etc by means of dragging and dropping
When I open my xib file in Interface Builder and click on File's Owner in the Document window, the Connections Inspector is showing far more actions below Received Actions than I have defined in the class as specified by the File's Owner Class Identity.
I have only two IBAction items defined in the class, and both of these actions are shown and hooked up to the appropriate buttons. I am not sure where these other ones are defined, as when I search the project for the text of the action shown, it is not found anywhere in my project. (I believe that the actions shown are from a previous software application that I did on this same computer.)
I cannot find any way to get rid of these, and while the application still works as it should, I would like to try to find a way to get these actions out of there.
I am using the most recently released iOS SDK 4.1.
You may need to just edit the xib file by hand and remove the invalid actions.
Due to some extraneous errors in a previous XCode project that wouldn't allow my iPhone app to run on the iPhone, I had to take all the code and files from what we'll call Project1 and build a new project called Project2.
I then filled Project2 with all the same files, not changing any code.
Next I had to recreate the Interface Builder files. As far as I can tell, this was done with the exact same classes declared in all the IB objects.
However, when I build Project2, it only shows a visible black screen and doesn't display the app.
The one difference I have found between the two projects is that in Project2's Interface Builder, the ToolbarController outlet is not even available for the view, and it is in Project1. I am assuming the lack of connecting the File View to ToolbarController is the problem.
Why is ToolbarController (as shown below) not available and how do I fix this difference?
Below are two screenshots. The first is Project1 and the second is Project2. :
alt text http://img32.imageshack.us/img32/8296/picture1xne.png
alt text http://img51.imageshack.us/img51/4194/picture3to.png
You've probably got the "File Owner" (or the "Toolbar View") set to the wrong class. Interface Builder doesn't see any outlets or actions in the classes you have set currently.