Why my Textfield appears as an IBAction?
check that you set class name in identity inspector tab for viewController
#Kiruthiga check class name of UITextField, and also check u should select IBOutlet instead of Action when u connect connection by dragging.This will help u
The fix is to define the custom class for the view controller you are wanting to connect outlets from inside the Identity Inspector (this same problem happened to me).
Select the view controller with the text fields you want to connect to code.
Go to Identity Inspector in the utilities panel and the first field should say "class" (Identity Inspector Image)
Fill this box with either the name of the file of the code you want to connect to the selected view controller, or you must create a new view controller file. To do this, you can go to File > New > Cocoa Touch Class. Then for "Subclass of" box put UIViewController, name it, then press enter.
The file you just created should come up as a .swift file (make sure this file is within the hierarchy of the app files as it tends to be created outside of it!)
Go into the "Class" box from the Identity Inspector and insert the name of the file you just created (it should come up automatically when you being typing).
Control-Dragging the text field to this file should now give you the option to treat it as an outlet rather than forcing it to be an action!
It's due to that LaunchScreen.storyboard - try in main.storyboard
You can change it according to your requirement :
Select collection type as outlet. Here you selected action which means action s that to be performed on clicking textfiled
Possible ways to get back.
1) Select UITextField if any class name already selected remove/clear it.
2) Maybe It looks like a problem on Xcode builds because of Object as Exit. So please clean and rebuild the project. try close project reopens it.
3) Check u should select IBOutlet/Outlet instead of Action when you connecting connection by dragging.
UITextField Can have IBAction of Editing Changed event. so you don't need to surprise on that part.
If you want to create IBOutlet drag to empty area not to IBAction function.
Hope it is helpful
Check your class...you have to assign a class to that ViewController....after assigning the class the problem will get resolved #kiruthiga
In my project, I want to display a popup and the view of this popup is defined in a .xib file.
To do that I use this line of code :
myPopupView = NSBundle.mainBundle().loadNibNamed("NibView", owner: self, options: nil)[0] as! UIView
Until then, it works. But the problem is when I try to add an IBOutlet. My Xib file is connected to a uiviewcollection, and I manage to create an IBOutlet on the Textfield I have in the xib file. But when now I run again my app, I have this famous message :
this class is not key value coding-compliant for the key...
So if I look on Internet, everybody says to delete the IBOutlet by clicking on the cross button in Inspector, BUT I don't want to delete it because I need this IBOutlet. So isn't it possible to have IBOutlet in a xib file ?
Thanks :)
This is very common error which means the IBOutlet you have taken in .xib is not connected to the relevant class. This kind of error I experience when i have taken a outlet and given some name like lblUserName but later i renamed that to lblFriendName, then the label in xib is still connected to lblUserName as well as lblFriendName, so at the time of compilation the xib did not find the connection for lblUserName and throws error.
So go to your xib, right click on the outlet in the xib, then you will see the cross button to disconnect. So disconnect it and connect it again.
During that also you can see the connection name, it must be wrong name or there would be two connection foe the same label in which one would be correct and another must be wrong (This case when you rename a connection as i explained)
Hope you understand, and it helps...
Happy coding ...
I renamed a class, which happened to have an outlet connection to a label called mainLabel in a storyboard file. When I run my program, it crashes and gives me the error: "this class is not key value coding-compliant for the key mainLabel".
Other SO answers have shown this to be caused by a bad outlet connection, so I removed the connection and removed any lose ends. When trying to reconnect the label to an outlet in my code, I get the error Could not insert new outlet connection: Could not find any information for the class named CourseTableViewCell
Other SO answers have provided solutions which I have tried and haven't worked including:
Deleting the reference to the file and re-adding it
Cleaning the project
Deleting the derived data folder
deleting the label and re-adding it
Dragging from the code to storyboard rather than vice-versa
I made sure that the correct file name was listed in the identity inspector, under "Custom Class". If anybody has any other ideas, please let me know!
I can provide more information if necessary.
The following steps are what you need to do to find existing IBOutlet / IBAction from and object. Be it label, button, etc. And how to remove it.
Open Main.storyboard. The Document outline window should be visible by default on the left of your storyboard window. If not, click the icon on left of the storyboard window, next to the View As: iPhone 7.
Select the object in storyboard, it's easier to find and then select it from the document outline of the storyboard.
Open the Utility window if not yet open on the most right side. Use shortcut key Cmd-Option-0 (command-option-zero), to toggle open/close of the utility window.
Open the connection inspector by click on right arrow icon (top right most icon). Remove any unwanted IBOutlet / IBAction or any other connection you want to remove by clicking on the x icon next to the connection.
Recreate the connection. You could also drag directly from the circle next to the element in the connection window for a particular object. Else add the connection the way you have been doing for now.
As for the Class file and other coding file. You could just comment out the lines that previously have IBAction or IBOutlet. And retype the same line manually (don't cut and paste). Add back the connection from storyboard, and you should be good. Don't forget to delete the lines you commented out that you don't need anymore.
After upgrading to Xcode 6, I opened an old project (that contains a subproject, so it has many targets)
and I noticed that no link from my Storyboard ViewContoller to the relative Objects works.
For example I have a ViewController with a TableView inside and now I cant do can't do anyhing with it because the connection is missing, I can't even redefine a new IBOutlet in the VC because the arrow in the storyboard from the VC won't connect to anything.
To be more clear:
The class is defined in the Custom Class section, so I can't find the problem
What should I do?
Btw I'm using obj-c not swift, I found some related answer but all about swift.
You can also see that the link between the parent view and the custom class is broken (not visible anymore) which is a huge problem.
I had the exact same issue with the app i'm working on actually, updating XCode from 5.xxx to 6.1. The workaround that worked for me was to remove the reference of every view controller and re-add them to the project...
To everyone facing that issue, here's the (annoying) trick :
Step 1 : select both .h and .m view controller files
Step 2 : remove the reference of those files
Step 3 : re-add the files to your project tree
Step 4 : open the storyboard, eventually re-build the project and smile
I can understand those things could be reaaally annoying, but it worked for me... Hope it will help someone else !
In your storyboard hierarchy select the View Controller,
In the right pane Custom Class section Class, select the drop down and your desired view controller.
I've experienced similar behaviour in Xcode 6.1.1 when trying to add the first outlet to a new view.
Tried removing the references and adding the files again as suggested above with no success.
What I did find worked was writing the first property on the new view by hand. I just popped in:
#property NSString *temp;
I could then attach my outlets in the normal way. Just delete the temporary property once you've added your first outlet.
Hope this helps.
It seems typing the outlet first (swift):
#IBOutlet weak var someViewOutlet: UIView!
and then dragging from IB the outlet to the far right type in the above code works.
Restarting Xcode resolves the issue (sometimes). Using Xcode 6.1
Maybe I can help
In my case the problem was that the viewController.swift file was not connected to the StoryBoard. The solution is to click in the Upper border of the view on the storyboard beside the 3 icons (View Controller, First Responder and Exit)...now look over in the Utility Area choose Identity Inspector, and in "Custom Class" choose the custom view controller.
Hope this helps. Xcode is hard!!
Here's the proper solution i believe.
If you renamed the controller in code, you need to update the .xib file.
I could not find a way to do it in the interface builder, so do this:
Open the .xib file with a text editor: right click the file > open as > source code
In the <objects> node find the <placeholder> node with the property placeholderIdentifier="IBFilesOwner" and replace the value in customClass="MyOldControllerName" with your new controller name: customClass="MyNewControllerName"
And all your IBOutlets will work as normal again.
Thanks to everyone who commented.
It is a bug of Xcode 6 / 6.0.1. Downloaded and installed the 6.1 version and the problem disappeared.
Maybe try to delete the outlet from the menu in the storyboard (in your screenshot) and drag it again of the element.
Okay, let's check iff it is the lack of a module name.
In your storyboard ViewController, type in the name of module. (the project name)
2.Clcick outside in another field. When you go back to the module field it may say none, but now there will be a dropdown menu entry for your project name.
Select your project name and see if everything is good.
If there are still issues I will post photos.
Seems to be a workspace issue. Try to remove project form a workspace and add it again. It helped in my case.
I had this, affected all projects on my machine, swift and objective c and drove me mad for ages. Finally also noticed that I could not use the refractor to rename classes either.
The fix for me was:
Close xcode
Delete ~/Library/Developer/Xcode/DerivedData (just doing this on its own did not work!!)
Delete all user data for all my projects using the following from the directory that contains all my projects e.g. /src (be careful with this command!):
find . -name 'xcuserdata' -exec rm -rf {} \;
If you want to do it by hand just do the following for all your projects
Delete .xcodeproj/project.xcworkspace/xcuserdata
Delete .xcodeproj/xcuserdata/.xcuserdatad
Get Spotlight to re-index the drive all my projects were on (not sure if this was required
Re-boot machine
Everything sprang back into life !
I was having this same issue.
It turns out I renamed my view controller class and file name. In storyboard, I had the stale value in the right pane, Custom Class -> Class. So the IBOutlets were not aligning because there were none in the missing class, which is where it was expecting to find the defined outlets.
Filling in the correct class name of the View Controller in the Custom Class field in the right pane fixed my issue.
XCode needs to be more verbose if you have a bad class name in the Custom Class fields.
no one solution fixed my same problem...
But i have solved by:
close xcode
renaming the folder of the project
open xcode
and then the outlets will be back again
I hope that this solution is the right one for the people who have the same problem
In Xcode 6.3 I needed to close Xcode and restart the Mac. Restarting Xcode alone didn't do it for me.
I've had 6.3 for a long time and my problem was with new projects I was creating to test some things. Definitely not an upgrade issue this time.
I have Xcode 6.3 and saw similar issue. Finally few edits in .h file resolved my issue. If your interface has IBOutlet defined as
#interface NavigationViewController :UIViewController
{
IBOutlet UILabel *lblName;
}
change this to and in .m file add #synthesize lblName;
#interface NavigationViewController :UIViewController
{
__weak UILabel *lblName;
}
#property (nonatomic, weak) IBOutlet UILabel *lblName;
I was having this same problem, with no view outlet available to link to. The only way I was able to fix it was to change the owner class of the XIB file to "UIViewController," make the link, and then change it back to my intended custom view controller class. The link stayed and all was well.
I have a ViewController class that is a subclass of UIViewController in an old xcode project. I want to use that same ViewController class in a new project so I am copying the .h and .m files to folder of that project. However, when I look at the .h file, the IBOutlets are automatically linked to the storyboard of the old project. I don't see anything in the .h or .m files that is pointing to the storyboard file of the old project. Why is this happening? Am I doing something wrong?
The connections (the little circles on the left side of the editor) are made by the storyboard or xib files and not by the .h or .m files.
The easiest solution to break that connection would be to change the class name (NewViewController or something of that nature). If that creates too many problems you could change the names of all the connections which would also sever the connection.
Basically, just find a way of making the circles on the left side of the editor empty rather than full.