Interface builder and subclass of UITextView - ios

I'm using XCode 4.6 and I'm trying to replace one of my UITextView's by a SSTextView from SSToolKit in order to add a placeholder to it. The SSToolkit library is correctly integrated in my project thanks to CocoaPods. So I just changed the type of the property in my view controller to be SSTextView instead of UITextView:
#property (strong, nonatomic) IBOutlet SSTextView *commentTextView;
And of course I also changed the class of the control in interface builder's inspector:
And yet, in my controller's viewWillAppear: the property is still a UITextView and when I set the placeholder:
self.commentTextView.placeholder = NSLocalizedString(#"Comment", #"");
I get an "unrecognizable selector setPlaceholder: sent to instance".
It seems to me like I've done that sort of things a thousand times and yet here, I can't figure out what I'm forgetting.

I figured it out. It turns out some parts of the compiled application seem not to be overwritten when redeploying to the simulator. So after I deleted the app from the simulator and ran it from scratch, it worked normally. I had other bugs like missing segues and so on so I looked that up and found out about the "delete app" technique. Weird...

Related

XCode 8.2 Can't connect interface builder IBOutlet to swift file

I'm looking for a solution specifically for the issue with a Swift3 UIViewController having IBOutlets defined, but dragging actions from storyboard does not connect them to existing outlets. I can add new outlets, just with different name, and they work (still cant re-connect them later).
I see old solutions for objective-C dealing with headers and source files, but a swift is a single file per class.
Is there a way to fix "can't connect IBOutlet to swift file" issue?
but dragging actions from storyboard does not connect them to existing outlets
I've noticed this too. But it's not a difficult problem. Here's what to do:
Look carefully at the gutter next to the outlet in the code. There is a circle. Drag from that circle (no need for control-drag) to the view in the Interface Builder canvas.

Xcode 6: can't connect any IBOutlet to ViewController

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.

-[UIView setHostedGraph:] unrecognized selector sent to instance

I am trying to use Core Plot to draw a graph, but I my graph view is instantiated as a UIView even though I've set it as CPTGraphHostingView in interface builder:
Here is my code:
usersGraph = [[CPTXYGraph alloc] initWithFrame:usersGraphView.frame];
usersGraphView.hostedGraph = usersGraph;
Why would that happen?
After playing on and off in Interface Builder trying everything again and again, I've started to search more on StackOverflow and I've stumbled upon this question: Application crashes when working with core plot
Pretty weird, but it wasn't and IB issue (I was sure I was doing the right thing in IB, I've done it a thousand times before), but a linker issue. I don't know why, but I had to add -ObjC to linker flags, and it worked.
Don't you think that it is strange?
For UIView to have setHostedGraph
-[UIView setHostedGraph:]
I think you have dragged the IBOutlet for that UIView into the custom class file before adding the CPTGraphHostingViewon the identity inspector. Remove the IBOutlet and drag again.
I downloaded the sample project from corePlot. Make sure that the IBOutlet is CPTGraphHostingView.

Interface Builder does not recognize outlet

It's been awhile since I've used Xcode and I resumed an old project I was working on awhile ago. I created a new UITableViewCell subclass. In my storyboard, I dragged a UITableViewCell onto my UITableView of my UIViewController. I changed the type of the UITableViewCell to my subclass, but when I control + drag from the UITableViewCell subclass to the UITextField, it doesn't allow me to make the connection.
.h of my UITableViewCell custom subclass
#property (nonatomic, weak) IBOutlet UITextField *titleTextField;
I must be going crazy because I thought this was something that just worked. I saw in another UIViewController that there is a custom subclass for the UITableView when I worked on this project last. I changed the subclass that was having the problem to that type of UITableViewCell subclass and I'm still not able to ctrl+drag to make the IBOutlet connection. Am I missing something here? Wasn't this something that always worked this way? Is there something new I'm not aware of? I tried using the assistant editor as well to drag it to the code, but that doesn't work either. I went back to the UITableViewCell subclass that DOES have a connection already made from when I last worked on this, and I tried ctrl+dragging to the label again, and it doesn't bring up the menu on which outlet I want to connect to either.
Another thing that is weird, is when I'm trying to type the custom class of my UITableViewCell that is already created, even though I built my project, it doesn't autocomplete it in the Class field. I'm not sure if my Xcode is having problems. Also, I don't know if this matters, but in my UITableViewCell, I Have some standard UITableViewCells as well. Any thoughts? Thanks.
It looks like all I had to do for my class name to appear in the drop down was to quit Xcode and come back in. I thought things like that would have been fixed in the IDE.
I found that I could still add the connections in the connections inspector. I don't know why they removed the very easy ctrl+drag from the left hand side of the storyboard unless I'm missing something.

How to get UIWebView working

(Link to errors here: http://imgur.com/a/AF87N)
I'm starting to work on iOS development, and I'm relatively new.
I was looking for tutorials on how to display web content in the app, and so I used the UIWebView.
In the tutorial I found I followed the steps exactly, but when I went to do the last step (linking the outlet) I got an error.
The two files I edited are DataViewController.h and DataViewController.m
This is the tutorial I followed: http://www.youtube.com/watch?v=NFffF9tRbak
I'm using XCode 4.6
Am I doing something wrong?
Renaming may still cause some erors, there is a chance, so its better to set the connections again.its quite simple.
You can solve this by following these steps:
1.
Click on the cross sign left to Web View , that will remove the invalid outlet.
2.then, connect the existing #property(nonatomic, retain) IBOutlet UIWebView *myWebView by control dragging the '+' sign left to the property outlet to your webview in the Interface Builder.
This will solve your problem, happens just because you are new to xcode. Will get better as soon as you get familiar.
EDIT:If its still not clear, see the screen shots below;
your outlet in yourviewcontroller.h may be like this now,
and in your xib,
it may look like this.
So what you should do is, just control drag the while blank circle left to #property outlet (first image) to the webview in your xib (highlightened one in second image). It will connect itself.
hope its clear now
Regards
Change your outlet name from webView to myWebView in outlets
Edit:
or change your UIWebView object name from myWebView to webView in your code

Resources