I am trying to give an object in the interface builder a custom class. When typing in the class name in the Identity Inspector it automatically finishes the line as its already present in the dropdown list of available classes.
However after entering the class the page comes up with a padlock image and clears the class name.
What is the cause of this and how can I rectify it?
firstly, you must reload xcode
if it not work you must have subclass associate with it in IB
Create CustomClass:UITableViewCell then drop UITableViewCell to IB and then just type the name
If dropdown list not display, reload Xcode
Assuming you've specific the right IB object (e.g., a dynamic cell prototype, whose default class is UITableViewCell) and your custom class is defined correctly (as a subclass of UITableViewCell, itself), then I have a couple of thoughts of what you might try:
Sometimes exiting and restarting Xcode is often enough.
Also try selecting "Clean" from the "Build" menu (or press shift+command ⌘+K).
In the worst case scenario, sometimes you have to exit Xcode and delete the DerivedData folder and then restart Xcode. To find the derived data folder, press command ⌘+, (comma) and go to the last tab, "Locations", and click on the arrow next to the "Derived Data" folder:
Having pulled up that folder in Finder, quit Xcode, delete the contents of that DerivedData folder in Finder (after quitting Xcode), and then restart Xcode and try again.
I think I have found the solution (not sure if I have found a fix for the actual problem or just found a way around it)...
I changed the Lock dropdown setting to Nothing and it now allows me to set my own custom class to the Object in the file.
Whats strange is that the document lock was previously set to Inherit (Nothing) anyway so not sure what the difference is here.
Related
In a project in XCode V8.2, using objective-c, I have created an object with a couple of properties. When I want to create a binding and start entering the property in "Model Key Path", IB shows me all available properties as expected and I can select the desired one. All is well.
On another Mac however, running XCode V9.2, this process does not work. I can enter a Model Key Path and the app compiles and runs without errors, but IB does not show me the available properties when I start entering the property name. When the name is complete (and correct), IB shows me a grey exclamation mark and a hint that it cannot find the Model Key Path.
Does XCode V9.2 and up require different/additional steps for this?
Ever since Xcode 6, when you bind objects from a Storyboard/xib file to a variable in your class, they often show not bound in the class.
So, finding the corresponding Storyboard/xib file then is more slow, as you have to manually go, and open the corresponding file (assuming you know exactly where that view controller lives among all Storyboard/xib file in your code).
There's seems to be no workaround out there.
Has anyone found the same issue? And along with this, has anyone found a workaround?
There are many disappointing bugs in Xcode, and this one of them. After you navigate to Storyboard containing these outlets, Xcode eventually find these bindings and will show them appropriately.
So, since updating, the gui randomly hangs editing a xib file. The scenario goes like this:
click an object - i.e, array controller
expand a parameter, Filter Predicate here
Select target object in pull down
try to enter model key path - HANG
In different xib files, the hang comes when trying to enter the model key path textfield. I've also seen errors citing bogus fields like 'Hidden3' for some attribute bindings - only workaround was to remove them.
Has anyone ventured to editing the xml directly, but I guess I can do that in code :-(
Well, I know this is an old question, but I found an answer.
My situation was similar to the one described above: Xcode hanging whenever I edited the key path of any binding in Xcode 8.1. Nothing described here or elsewhere worked.
However, what did work was to edit the storyboard outside of the actual Xcode project: open the offending StoryBoard by itself, do not access it through the project.
This appears consistent with a Sample/Spindump through the Activity Monitor when Xcode hung that showed functions that appeared related to auto-completion/edition. Unchecking auto-completion did not work though (in Prefs).
My question is on how custom controls should be updated.
I downloaded this owner drawn custom control, which I built, then copied the DLL to the Debug folder of the project and loaded it into the toolbox from there.
I decided to use this button on another project. I was mildly surprised to see the control was still in the toolbox but it seemed to work just fine. I decided to change this custom button's behavior. The button in the toolbox referenced the old version number. So I deleted it and loaded the newly rebuilt DLL.
Now come the problems. The first application--the one where the DLL was added to the toolbox from--still runs okay, but the second application is throwing errors, saying, Type 'CButtonLib.CButton' is not defined. When I add the button to a form, it appears okay. I can change its properties and it shows up in the code windows and in the object browser. But as soon as I try to run it and it throws the errors, it no longer appears in the object browser. References in the code window lose their intellisense.
Things I've tried include:
Copying the DLL to the project's debug and release folders and loading them into the toolbox from there.
Removing it from the toolbox altogether and just adding a reference then copying and pasting a button directly from the first project.
Copying in a form with a CButton on it from the first project.
Scouring the internet for answers
Swearing at the computer.
Nothing seems to work and I've now spent over a day trying to solve this.
I never did get to the bottom of this. In the end I simply had to recreate the entire custom control project using a different name. I suspect the way I added the original project to the toolbox of a different program – as opposed to adding it within the test project it came with – may have had something to do with it, but that's just a guess. Anyway, I can amend and update the new control without problem now, so all's well that ends well. :-)
I started to create an app using tabbar app template provided in xcode. Then I wanted to change the names of the files: FirstViewController should become YellowViewControler and FirstView.xib should become YellowViewcontroller.xib. Changing the name of the xib wasn't done right. It became red as if it didn't exist in the project. So: how should I change the name of the xib files?
Use the "Refactor" tool of Xcode.
This will manage the renaming of the XIB file, the renaming of the interface & implementation of the source file containing the definition of the ViewController, the renaming of your class declarations/definitions, and any references that are used anywhere in your projects, all of this in one action.
Rename the stuff back to what their original name was (FirstViewController) and then go to the interface file for it (.h) and right click on the class name (FirstViewController) and click refactor. This should make sure everything gets changed correctly.
Source this question
Most likely your viewcontroller name still linked to previous owner therefore open the viewcontroller.xib in source code and find the owner and changed to current name. It will fix the problem right away.