I duplicated a .xib file and a swift file to adapt to another view quickly. But now from my initial .xib there all my outlets (from this view) have 2 components (the initial and the new created):
How can I remove a link in my case?
Thank you very much!
With right clicking on the object and then click on x.
Or from the connection inspector in the right hand side of the Xcode:
Related
Why can't XCode 4 create XIB file while using storyboard: is it 2 incompatible models ? For example all tutorials about hiding keyboards seem to require XIB file:
http://www.techotopia.com/index.php/Writing_iOS_4_Code_to_Hide_the_iPhone_Keyboard_%28Xcode_4%29
Here is an update to the link in the question:
Having written the code for our method we now need to wire up our user interface so that it gets called at the appropriate time. We will perform this task in Interface Builder, so select hideKeyboardViewController.xib once more.
The equivalent of this now is to click on storyboard, and then click the hidKeyboardViewController in the storybaord window.
Select the text field in the view and display the Connections Inspector (View -> Utilities -> Connections Inspector) in the right hand panel.
The equivalent of this now is to Right click the text field.
Click on the circle to the right of the Did End on Exit event, drag the line to the File’s Owner icon and select textFieldReturn from the list of available methods.
Equivalent here is to click the circle, as mentioned, then drag the blue line to the orange box at the bottom.
Its the same, inside the storyboard you will see your views and you can do the same as you did when you were working directly with .xibs
Treat the "scenes" in the storyboard as if they were XIBs. You can layout the screen, add elements, and link them up to their respective ViewControllers. Any code you need to run should be in a ViewController, and then in the Storyboard you can indicate that a particular scene is related to that ViewController.
For your question about hiding the keyboard, you'll need to have a method in your ViewController that includes a line of code:
[myTextField resignFirstResponder];
...where myTextField is a UITextField, UITextView, or other object that requires a keyboard.
I started an "Empty Application" template, this means that I had to add my own storyboard file. Problem is, it is completely blank, and I can't figure out how to get the first view on there, so I can start designing my interface.
Anyone know how to get that first view on there?
When you create a new Storyboard file, all you need to do is click/drag the UIViewController object from your right hand side of tools into your Storyboard and then you're all set to begin work on your new Storyboard.
Just in case you can not start from scratch :
Select your View Controller
Open the Attribute inspector (right pan by default)
Go to View Controller section
Select Is Initial View Controller checkmark of the Initial Scene option
In the latest version of Xcode (12.2), this is how you can add initial view to story board
Click on + Icon,
search "View Controller", Drag and drop View Controller.
Go to Edit->Show Library then drag and drop a type of View Controller that you need.
I seem to be having an issue. The tutorial I am following from Apple's Dev Center says:
Control-drag a connection from the
Convert button to the
ConverterController instance in the
nib file window.
A black box will pop up similar to
the one we used to connect outlets.
Choose convert:.
Save the nib file.
I usually hold ctrl and drag the mouse from one object to another. However, when selecting a button from my User Interface and trying to drag to an Object in the xib window (this is all in the Interface Builder), the object will not highlight. It just won't let me do it!
Any ideas why this is happening?
you can use the "tree" map of all the objects in your nib file so it is easier to select one. this is helpful if they are on top of each other, hidden, or otherwise difficult to click directly. in xcode 4, there is a little triangle button along the bottom left of the nib view; if you click it, a sidebar opens with a text outline of all your nib's object. you can click the button in this list so it highlights, then control-drag to your file owner to attach it to a method you have written. the sidebar is also useful if you want to re-order objects in a view or subview, to make some on top of others.
Right click the file owner file a pop up will appear in front of you their you can see various action methods that you have in your project.
select a particular action method and then assign it to the appropriate button on which you want to call the appropriate function.
At some point I deleted the Object to my appdelegate file for some reason from the XIB. I added a new object, and selected MyAppNameDelegate as the class. However, it's not connected to file owner, and I dont seem to get the option when right clicking and dragging. I think this is causing me some runtime issues. Any ideas?
If you are referring to your MainMenu, the the file's owner is an object of type NSApplication.
In IB, you should select your file's owner, access it's 'delegate' outlet and drag it (as to draw a line) to your app delegate. This will restore the connection.
Check also that your file's owner has got the NSApplication class type. Maybe it got changed somehow.
I had this same problem. I found a lot of half-answers on different threads, so I decided to put them together here.
Drag an NSObject instance from the Objects palette to the area below "Objects" where the objects for your xib are listed (click on the triangle at the lower left if you can't see it) for MainWindow.xib. The object should show up as a solid orange box.
Select this newly-created NSObject, and change its class to the name of your new App Delegate (whatever the file name is without the .h or .m), using the Identity Inspector. This should be an option in the pop-out list.
Control-drag from the File's Owner to the new object, which should not be displayed as " App Delegate", and select delegate.
You will also probably have to reconnect the Window (and possible other views) to your new delegate. Do this by dragging from the App Delegate to the Window and selecting window.
Hope this helps.
This was driving me nuts also.
I marked +1 above, the answer does in fact help, the answer is cryptic, so this will help explain in finer detail how to get a delegate or another connection that won't link directly into the file using the "Assistant Editor" view.
right click = control key + left click.!
IN XCode 4. Select any of your XIB files. Say for a UIScrollView you added, you want to set the Delegate for it. Well unlike the prior IB where you just open up connections inspector, and drag a connection to the file. Its actually just the same here. BUT a difference.
(NOTE:The dock is panel 2 from the left. Only with a XIB open)
Open up the Dock > http://developer.apple.com/LIBRARY/IOS/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/InterfaceBuilder/InterfaceBuilder.html
There is a small triangle arrow there at the bottom of the Dock.
At the very top of the Dock is "Files Owner", without the dock opened, it is the white box with orange trim.
Select the view or what ever needs delegate access to the File (UISegmentControl drove me nuts on this too), right click and drag a connection on "New Referencing outlet" to the Docks "Files Owner", and a list will pop up.
Like wise, you can right click on the "Files Owner" and remove connections easily there, or make new ones.
I'm working on my first iPhone app and have been able to get most things done. There's one problem that I've run into a few times and I want to understand the issue better.
In XCode, if I go File->New File->UIViewController subclass and make sure that both UITableViewController subclass and With XIB for user interface are checked, then it creates a MyViewController.h, MyViewController.m, and MyViewController.xib.
When I look at this xib in Interface Builder, you can see that the File Owner has an Outlet called view that is already connected to the UITableView. No problem. This all makes sense and is great.
My issue comes when I've changed the type of my class (or done something else) and some how the "view" Outlet goes away. I get an error saying "view not showing up in file owner outlet".
My question is how do I then reconnect the UITableView as the "view" of the ViewController when the Outlet goes away? The only way I've been able to get it to work is to literally start over with a new xib/viewcontroller.
That "view" outlet should be coming from the parent class (in your case UITableViewController).
What do you mean by change type? If you are changing the name of your class, try using Edit > Refactor with the class name selected in Xcode.
In the "Document" window (cmnd + 0) - control + click on file's owner, a weird looking line thing will show up. drag the mouse over to your view and release. a little drop down will come up from which you can set the view to the File's Owner View outlet.
Typically the "view" outlet would be coming from the parent class (UITableViewController). If it's not showing up, then Interface Builder is not connected to your project than this could happen instead.
My problem was due to an edge case as described here: Interface Builder and Xcode integration not working