I'm creating app, using IB. But File's Owner doesn't want to work! I can't see, what in it, can't drag line to code from buttons in IB.
In code, all's okay. Connection with First Responder is wokrs nice, but it isn't that i want.
For example, now i can't connect UIButton with it's IBOutlet, cauze, when I drag line to code from button, there are nothing happens.
What's the problem?
Thx,
Maxim.
Set the file's owner's class in IB:
Select the file's owner (by clicking on it)
In the utilities area open the "Identity Inspector".
Set the topmost field "Custom Class" to your file's owner's class.
Related
I recently updated to Xcode 11 and some of its user interface changed. in older version of Xcode there was options of accessing files in assistant editor using automatic or manual. but in this version of Xcode I can't see any manual option in assistant editor. so I am not able to add IBOutlet and IBAction methods to particular storyboard.
so can anyone tell me how to add these actions and outlets, that would be great help. thanks
By pressing the above button, Xcode will split the view and allow you to select a custom file using the file tree at the top.
You are correct.
The Manual option is no longer visible. You can still achieve the same result by doing a quick open using Cmd+Shift+O then type the name of any file you want to open. Press the Alt key and the file will open in the Assistant Editor Window.
As others have noted the new add editor button allows you to add new editors and open files into them. You could file a bug report but you may want to consider that you're likely to get a "works as designed" type of reply.
You can always change or add new keyboard shortcuts to get the behavior you want by viewing the preferences key bindings area and search for the command you want to shortcut.
Note
You can still ctrl+drag from storyboard to the class by the Adjust
Editor button in the upper right of the storyboard. Then just select
Assistant Editor on the list. After which you can make IBOutlets/IBActions.
open your storyboard, hold option key and select the file you want
In the documentation outline of storyboard, try to choose the "correct" item, which you want to set up outlet connections. Say you want to set up an outlet connection for cell of table/collection view.
View Controller > Collection View > Cell > Content View > Image View.
Try to select Cell, "Content View" or "Image View", then check the jump bar of assistant editor, you're probably able to switch to the .swift file you want.
Reference
I'm having an issue connecting the view and IBActions/Outlets to File's Owner in Xcode 4.2's nib. When I create a new nib file, I'm going to File -> New File -> Select UI on the right -> Select "View" -> Device Family of iPhone -> then save it as TestView.xib. The new nib appears, but when I try to control + drag from File's Owner to View or anything else, nothing at all happens, the line just disappears without letting me select it as an outlet. The same issue occurs when I try to connect IBActions, Pickers, Labels or really anything to File's Owner. I cannot connect anything to it.
I'm working through a programming book that provided source codes, and when I play around with the nibs in there, everything is already connected to File's Owner. I can reconnect everything just fine in those files as well. I've been having to type up the program and then drag and drop the source codes nibs rather than being able to do it myself.
I'm sure that there is something little that I'm missing, and I've been doing research on it and trying to figure it out for days to no avail. Any help would be much appreciated, thank you!
My guess is that you have not set the class for File's Owner correctly. Select File's Owner in the vertical bar on the left of the Interface Builder view, and in the Utilities (right) bar, go to the third tab (Identity inspector) and set Class to be your view controller's class.
Is there a keyboard shortcut for jumping from the current xib file to it's class (ViewController)? And back from it's class to it's xib file again?
I use ctrl-command-up/down all the time to to jump between header and source, be great to have one for the view xib also.
There are a couple of quick ways to get to the XIB associated with a class.
CTRL-5-↓-enter
This will open the jump bar to the current file. Assuming your XIB is named the same as your class -- which is usually good practice to do -- the matching XIB will be the next item in the list if you are in your implementation file, or two down if you are in your header file.
Alternately, you can open the XIB or StoryBoard associated with the file with one mouse-click if you have an IBOutlet.
See the outlet indicator next to the IBOutlet?
Click on it!
For additional Xcode shorcuts, a great resource is this PDF maintained in github:
http://cloud.github.com/downloads/Machx/Xcode-Keyboard-Shortcuts/Xcode_Shortcuts.pdf
I don't know if there's a keyboard shortcut for jumping from xib to corresponding class header file. But you can do that easily with a few mouse clicks:
Select a UI object in storyboard
Select "Identity inspector" in Utility Panel (3rd tab from left)
Click right-pointed arrow in the class name text field on top, which will take you to the header file
You can always go back and forth with two-finger swipe in Editor panel
Most shortcuts can be seen here:
http://cocoasamurai.blogspot.com/2011/03/xcode-4-keyboard-shortcuts-now.html
And although that would be an awesome one, don't think it exists.
When I create a new cocoa project in Xcode, it creates a MainMenu.xib file with a Window. I would like to separate the window into a MainWindow.xib and have that show up as the main window - how do I do that?
If I create a 'document' based application - I see two xibs (MainMenu.xib and MyDocument.xib) and I notice that MyDocument.xib gets displayed right away - but I don't understand where this is identified. There doesn't seem to be explicit code and I'm not sure where to look in the plists.
If I create a new Document, how can I make it the primary window that shows up when I start the app?
in <YourProjectName>-Info.plist you'll find the key "Main nib file base name", with the value of the first xib to load usually "MainMenu".
Also you'll find "Document types" -> "Item 0" -> "Cocoa NSDocument Class" and there the value "MyDocument". In the class "MyDocument" there is a method - (NSString *)windowNibName. This return the name of the first xib to load.
Window management is your responsibility. Don't rely on the frameworks to display windows in any order, as that order is undefined.
Firstly, make sure that the Visible at Launch checkbox is not checked for your windows in Interface Builder. If it is, you won't be able to control window display effectively. It's on by default.
Next, use an NSWindowController subclass for each window nib that you want to load. Then, in your main application controller you can control when those NSWindowController objects are instantiated and when to call their -showWindow methods.
In your example case, you'd probably instantiate the NSWindowControllerfor your MainWindow.xib in the ‑applicationDidFinishLaunching: method in your application delegate.
I am trying to learn iPhone development and someone passed along the website www.appsamuck.com. On Day 1, the tutorial instructs the developer
We need to reference the label in our code so we can update the label
* In the document window "File's Owner"
* Click: Tools->Idenity Inspector
* In the inspector click the + under "Class Outlets"
* Change myOutlet1 to "countdownLabel"
* Change id to UILabel
* Click enter to make sure they commit
I really don't want to get hung up on this, but I can't find "Class Outlets" either when creating a new project from scratch or opening the zipped source code project. Is this just a difference in versions of Interface Builder? Where did it go?
Class outlets are used to connect objects defined in Interface Builder with ivars and properties defined in the source code. The feature you are looking for has moved since the tutorial was written.
In version 3.2.2, you want to click the File's Owner in the document window. Open the Object Inspector and click on the Info tab icon. Here you can set the class name. You can click the gray arrow in the class name text box or open the Library window. In the Library window click the Classes tab at the top then click the Outlets tab at the bottom. This is where you will see the list of outlets and can add or remove outlets.
Here's a screen shot that might make it easier to follow the steps:
http://skitch.com/kirbyt/n6wm3/classoutlets
Hope that helps.
-KIRBY
Yes, there are various flavors of the Interface Builder that comes with XCode. Especially 3.0 and tutorials written prior that version are a serious pain. You can find the Class Outlets in the Inspector pane. The icon that is blue with a little 'i', is where you should click on.