I can not connect view controller to code using windows keyboard - ios

I started to learn IOS development. I am going through a video tutorial. The instructor is connecting the Hello World to the code by pressing control and using the mouse, as you can see in the screenshot :
I have windows 7 machine. I rented a mac VM from xcodeclub. When I tried to press control and connect the viewcontroller to the code by dragging mouse as done by the instructor, it do not connect. I am using windows keyboard. So how to do this ?
Is any other way to do this ? Or I have to use some other key + mouse drag ?

Fix. Try right clicking on the label and dragging from new referencing outlet.
Otherwise, check to see if your view controller is the correct class. Click on your storyboard file (probably called main.storyboard or something similar) and select the graphical representation of your view controller. Then, on the right hand side click on the small icon that is the 'identity inspector'. Make sure under custom class it displays UIView. If it doesn't, change it to UIView and try again.
If that doesn't work make sure you're dragging the blue line across the screen so that when you release it you are between the #interface and #end lines of code. Like this:
#interface
// drag it here...
#end

Related

Can`t drag #IBOutlet from swift file to storyboard ViewController in Xcode 7.2

I use Xcode 7.2
I can use Control+drag to swift file to create a #IBOutlet
But I can't drag #IBOutlet in swift file to storyboard. Here I don't use any other key, just drag.
Actually when I moving mouse to the spot before #IBOutlet, nothing happened and when I trying to drag it a breakpoint added.
1.I`m sure I use the right Class name
2.My project is not in a strange path or name
don't use Control, only drag with mouse from circle icons.You can see in the picture below. Circle icons in red box
Changed Behavior
The behavior has changed in new versions of Xcode (I'm not certain but it might have been since 7+.). Older versions of the product might still have the gutter shortcut working.
Now you have to either open the Connections Inspector or right-click on the view controller in the Document Outline. Once open, drag from the defined IBOutlet to your UIView subclass (UIButton, UITextField, etc...)
Connections Inspector
Controller View
Official Guidance
Search your local help for: Interface Builder Connections Help: Creating an Outlet Connection. You will find these are the only methods that now work. The gutter shortcut does not work.
Nota Bene:
You can confirm this behavior and other changes to Xcode shortcuts by
choosing the following menu Help > Xcode Overview and
taking a look at Part V: Building a User Interface, section Connecting Objects In Code.

Wiring up Outlet Collection Trouble

From what I can tell there are some challenges people are having in XCode6 in terms of wiring up outlet collections. I just wanted to see if i'm doing this right or what I need to do correctly! I reviewed here Can't hook up an outlet collection in Xcode 6 using storyboard as well as other areas, but I wanted to be more basic about this first.
I have 7 images on a screen. I'd like to iterate through all of them in a loop or something. I read an outlet collection would be a sensible way to do this. To create an outlet collection, I am doing this:
While splitting the screen (storyboard on left, assistant editor on right) I control+click on one of my 7 images, and drag it into the view controller code on the right. This will prompt me to create an outlet, or outlet collection (I select outlet collection).
Now that this is done, a circle appears in the left margin next to this variable indicating that the image is associated with that variable. If I hover over the circle, the first image lights up.
What you're supposed to do (can someone confirm this please??) is you just hover your mouse over the circle, and a + symbol appears, and all you do is hold down the left mouse button, and drag over to another image (for example image#2), and it should automatically add that to the collection. The idea is to simply drag to each image so they are all added.
Is that right in step #3 above? Is this the normal way you would add items to a collection? Drag from the + to the image within your controller? For me, when I do this, the line appears, but it doesn't seem to respond to connecting the line to anything. I just hover it over the images, and it doesn't highlight the image or select it or anything, and when I let go, nothing happens.
I'm still somewhat new to this - what am I doing wrong?
Thanks so much for your patience/help!
OK I had the same issue and I think I have just found a workaround
1) Do steps one and 2 with the first image
2) Now repeat exactly what you did using the second image - drag and drop just below the first outlet collection (this would simply create a second outlet collection use exactly the same name )
3) Now Xcode won't like it as you have two outletCollections with the same name. Now comment out the first one
4) Now you only have one outlet collection. And it would be wired up to both your images. confirm it by hovering your mouse pointer over the little 'circle' next to the IBOutlet to see your images being highlighted.
This seems to work for me. So hope this helps :-)
There is an error with Xcode and Interface Builder that causes problems with outlet collections. You are doing it right, Xcode is problematic.
A workaround is to:
Go to your DerivedData folder (Xcode preferences -> locations)
Clean build folder from the Product menu while holding option (alt) button
Quit Xcode
Delete the folder starting with your app's name in the derived data folder
Go to your xcodeproj file, right click it, show package contents.
Delete the xcuserdata folder (warning: don't touch the others!)
Open Xcode again.
When you delete user data, window positions etc. will be reset to defaults and breakpoints will be deleted. Your project should work smoother (after a few seconds of re-indexing) and outlet collections should work properly.
I have had some success by just changing my workflow as follows (no need to restart Xcode).
First, create the outlets in code in the controller class file.
Second, drag from the objects (in the outline view of IB) to the controller, or back (for actions).
This has always worked without fail. It is slightly more effort, but actually negligible. Definitely an Xcode bug.

I messed up Xcode somehow

So I'm learning Objective-C and making iOS apps, but I seem to have done something to Xcode and everything looks all messed up.
Here's what I'm talking about:
The UIViewController / StoryBoard is WAY to wide, it auto-sizes to that right when I begin a new project:
I'm missing the items like "New UIView Controller" and stuff, I've searched every tab:
EDIT: All issues have been fixed, but when I add a new UIViewController, I don't get the ViewController, just the files!
For your first "issue":
From what I've seen in a WWDC movie, this is the 'universal' view of a Storyboard, which is device-agnostic.
I believe you can select a specific device in the bottom of the UI, where it says 'Any'.
The UIViewController / StoryBoard is WAY to wide, it auto-sizes to
that right when I begin a new project:
You can simply zoom-out using Editor > Canvas > Zoom > Zoom out or by using your touchpad or by using the shortcut Alt + Cmd + 8.
I'm missing the items like "New UIView Controller" and stuff, I've
searched every tab:
You simply create a new Cocoa Touch Class and in the next prompt you will be asked for the desired subclass. You type in: UIViewController.
EDIT: All issues have been fixed, but when I add a new
UIViewController, I don't get the ViewController, just the files!
So with you "don't get" you mean that your ViewController in the Interace Builder is not yet connected to your "files", right? Just click on your designated ViewController in Interace Builder and press Alt + Cmd + 3 to open the third Inspector-Tab and type in your class name "dashboard" into the first textfield.
You can also change the size of the storyboard device by clicking on wAny hAny button at the bottom middle of xcode.

Editing toolbar in Xcode 4.6 - unable to add Bar Button Items

I am attempting to add a toolbar as an input accessory, and as such have added it via xcode storyboard editor to the view controller (and not within the view). This was as specified in this tutorial(which seems to be written for an earlier version of xcode): reference
My issue: "8.) Now we need to open the toolbar item itself. Double click Toolbar in the document window."
This is no longer valid behavior in Xcode 4.6 it appears, so I ask you: how do I add button items to a toolbar? I would prefer to avoid doing it programmatically (Still reasonably new to xcode development and normally make my GUIs with storyboards) but if I have to, I have to.
Many thanks!
If you're doing what I think you are doing, adding UIBarButtonItems to a UIToolbar, then you simply drag a Bar Button Item out to the toolbar.
However, I would assume that what they mean when they say 'double-click' is not what people normally think of when they think double click. Try double clicking slowly this often does the trick.
Found the issue - it was appearing behind the UIView. However you dont ever need to graphically interact witha toolbar, you can just drag-and-drop controls onto it in the sidebar. If there is a need for more info on this message me or vote up.

Link view button with the code

I am learning IOS development, and I have a question about the connection with the view (designed on Interface Builder) an my controller, that has the code. How can I connect both and make things like set a properties, etc.
There are a few ways....
The quickest is with Xcode 4+ using Interface Builder and Assistant view.
Open your NIB (xib file) and touched the Assistant view button at the top right of the screen, looks like a tuxedo (outlined in red in screenshot below). This will load the associated interface/header file for this NIB.
Select your button and hold the CTRL key and drag to your header file and point where you want the declaration to be placed as seen below.
Release the mouse and setup the connection as shown below.
Once this is completed you will have a method added to your implementation file where you can write your code for what happens when the button is touched.

Resources