Xcode Outlet/Action connection UITextField - xcode

I'm trying to add my text field as an Outlet in my ViewController.swift, but when I drag the text field from the Main.storyboard to the ViewController it only shows as action and I cannot change it to Outlet.

I had this problem too! I fixed it by clicking on the top bar of my UIViewController (in the storyboard looking window), then selecting the Identity Inspector on the right and in the top where it says Custom Class in bold there is a field called Class which I set to the viewcontroller file I was trying to control-drag the UITextField to. Once the Class was set to the right name I was able to control-drag for an outlet. I hope this helps.

Related

Dragging UIButton on UIView in Interface Builder not working

I created a new Xib file, called MainViewController.xib. I dragged a View onto the builder, then plopped a UIButton on top of the view. Nothing happened, my button is on the view but not considered a subview. There is no hierarchy tree on the left column under the View icon that tells me my button is a subview.
Why is that? Every time I control+drag from the button to the view icon, the information for constraints pops up, instead of anything regarding an IBOutlet connection.
I'm using Xcode 7.1.2
I can control+drag to from my button to my .h file and create a property, but other than that, it's not recognized as a subview. Any help at all will be appreciated, I'm losing my mind.

Creating an outlet for a NSProgressIndicator inside a NSToolbar

I have this OSX storyboard-based application that starts with a NSSplitViewController like this:
This splitViewController has two viewControllers: master and detail.
Inside the window I have a NSToolbar. I dragged a NSProgressIndicator to that toolbar and Xcode embedded it inside a NSToolbarItem.
Now I need to create an outlet (not an action as explained on other stackoverflow questions) from the NSProgressIndicator to some class. First question is which one?
Xcode will not let I create an outlet. I have tried these options:
dragged from the ToolbarItem to masterController class file, detailController class file and to NSSplitViewController class.
dragged from the ToolbarItem to the delegate class.
dragged from the NSProgressIndicator to masterController class file, detailController class file and to NSSplitViewController class.
dragged from the NSProgressIndicator to the delegate class.
dragged from both the NSToolbarItem and from the NSProgressIndicator to the Window Controller First Responder.
In all cases dragging does not make a window appear to allow me to create the outlet.
For heavens sake, how do I create an outlet like that? To which class I drag it and how do I do that?
I'll assume your setup is more like this image:
Your Window scene is backed, by default, by an NSWindowController, to which you cannot add new outlets. You need to create a subclass of that, associate it with your Window and then you should be able to create outlets in that.
File > New File > Cocoa Class
Specify a name like "SpaceDogsWindowController", as a subclass of NSWindowController.
Then use select the window controller icon (blue circle) and select the Identity Inspector in Xcode. (CMD+ALT+3). Specify the name of your new class in the "Class" field.
Then try to hookup an outlet:
1) Show the Assistant Editor
2) Use the Jump Bar to ensure your custom class is visible (It's at the top of the assistant editor pane, it should say Automatic and you can tap that to then select your new class; If it says 'Manual', change it to Automatic).
3) If your are control-dragging and it's still not offering to make a connection, try dragging from the document outline (also shown in the screen shot).
You could then edit that progress indicator from other view controllers, which are descendants of that window's view hierarchy, using code like this:
if let windowController = self.view.window?.windowController() as? CustomWindowController {
windowController.progressIndicator.doubleValue = 0.4
}
or, in Objective-C, something like this:
CustomWindowController *myWindowControllerSubclass = self.view.window.windowController;
windowController.progressIndicator.doubleValue = 0.4;
Hope that helps.

xCode can't Control-drag into .m file

I'm trying to change the results field in the sample app SimpleURLConnections in the AppleDeveloper Library from an Image View Object in the GetController.m to a Text View so that it will display responses that aren't images. (I know some code that checks the response type also needs to change.)
When I drag a Text View object (or ANY object) from the Utilities pane to the MainWindow.xib in the editor pane, it appears to be created ok but when I try to Control drag from the Text View into the #property area of GetController.m, I don't get any "Insert Outlet.." popup or new entry in the GetController.m file? (By experimentation, I can get it to populate an IBOutlet in the AppDelegate.m file.
What am I doing wrong?
Thanks,
Rick
It may be because you are doing it wrong.You added the textview to mainWindow and Getcontroller is a controller entity[its a view controller i think.] .An xib will be connected to the outlet if and only if it has the custom class correctly set to that class.
Add a view controller with custom class in attribute inspector set to that Getcontroller and then you can connect the outlet
When u drag the control to the **.m , u should press the key "control",

Can't CTRL+Drag NSButton to custom NSView header

I'd like to create a custom NSTableCellView instantiated by Interface Builder. I've set my Table Cell View class to MyTableCellView, and properly created MyTableCellView : NSTableCellView .m/.h files.
However, I just can't CTRL+Drag a simple button from inside this view to MyTableCellView.h in order to create an IBOutlet.
Here is a video to show what happens: http://youtu.be/sNNbuVT-SZs.
How the view is subclassed:
How I try to CTRL+Drag a button
Also, sometimes, Interface Builder just don't allow the cell view's class to be modified. What's happening ?
I finally found a solution, that is a little weird but works as expected. Instead of connecting the NSButton to MyTableCellView header directly, I used the reversed path:
Manually create an outlet:
#property(retain, nonatomic) IBOutlet NSButton* button;
Then click the empty circle on the left, and drag it to your XIB file's button:
I have no idea why it works this way, please let me know if you know the anwser.

Interface Builder won't allow me to select a nib name for tab bar

I just upgraded to xCode 4 and I am having so much trouble setting the nib name for a particular tab. If I choose nib name it drops down a list with nothing, if I just type in the nib name I want, when I run it, it does not show that view. And I have specified the class for that tab. I have a tab bar and a navigation controller set to one of the tabs.
Thanks
You can add an uinavigationcontroller to your uitabbarcontroller.
Now you can add an uiviewcontroller to the added uinavigationcontroller.
Now you can change the class of the last added uiviewcontroller, and set the nib-name for this item.

Resources