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
Related
I am using the charting library here https://github.com/danielgindi/Charts/ however I am having a couple of issues.
First, I have no idea how to set the data for a radar chart type and second, I have an error when apply the RadarChart to uiview. The error is
Unknown class RadarChartView in Interface Builder file.
The app still runs and I can see an empty uiview.
I have looked at the demo app and through the documentation but I am still unsure how to actually set any data to the chart.
Thanks
If you looked at ChartsDemo app, why you still not unsure how to use it? The code is straightforward. Otherwise I am still copy pasting code from ChartsDemo, which is meaningless.
For the class, you need to choose Charts module for your IB: https://github.com/danielgindi/Charts/issues/59
downloaded library
reembedded it with the option "Embedded Content Contains Swift Code"
In Storyboard where I defined the class for the charts view as "LineChartView", I also have to set the module manually to "Charts".
I created a new project of type Static Linked Library.
I have moved the code (previously working in the app) to the library leaving all the xib files in the app.
I have changed the export directory and added the library file from the derived data folder so it gets the compiled version and links to it.
I have added the library to the bundle and have verified it is in the app using iPhone Explorer
I have verified that the xib file recognized the new view type by removing and selecting the custom view type in the custom class field of the identity inspector.
I have changed all of the #import commands to reflect the <> VS "" change and have gotten the app to compile.
however none of the methods of my custom class can be executed. and an NSLog reports that the class is its base counterpart as opposed to the custom derived class.
I am at a loss and have spend a long time converting all the code I have to work in a library. I am hoping someone can help with this.
On this issue, it turns out that Objective C's compiler does not load the categories and custom classes in the libraries by default. There are 2 ways to overcome this.
And here are your options.
Create an Activation type method on the category that will be called to "Activate" that Class or Category. This will need to be done before the application loads any nib files. And seems like a bit of a pain in the butt. This was however how I originally overcame this issue.
Add linker flags that will tell objective C to load all libraries and attach any and all Categories and Classes within the libraries before executing the application. (this will need to be done, on top of #import(ing) the correct files from their correct locations. I will provide a graphic below. and provide the flags for search purposes
-ObjC is the first one I added, but -all_load really did the trick.
I hope that others can benefit from this experience.
I am working on a project which includes many UI components on one view(being built in Interface Builder). I have found that after saving and moving my project directory, the interface which should include all of these elements, is empty(there are no visible UI components in the view).
There are actually 2 projects. 1 is a framework project, the other is the iphone project which i build & run on the device - everything is contained within a folder which i may move frequently as other members in my team work on it.
the view which is not properly showing elements, is an XIB file which can be modified through either the iphone project or framework project.
Why is this happening and how can i troubleshoot this problem further? I am not sure how to fix it.
Many components will not show if they're not been connected to a property, and some will not show if their datasource or delegate is not connected.
Have you wired everything up, making all of your connections?
Could you check the view hierarchy in the -(void)viewDidLoad ? As Matthew said, if those components are not connected to properties, they won't be shown. And, if they are not add onto proper view, then they won't be shown too.
You can check the view hierarchy of viewController by browsing the property subViews of self.view.
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.
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).