Xcode add connection doesn't add function - ios

I'm using Xcode. I've just added a button in the storyboard. I control-drag to the implementation file. The function doesn't show up in the implementation file. Strangely enough if I do a search with on the newly added function it DOES show up in the new screen in the implementation file.
How can I solve this? Because it's time consuming not being sure the function was added and not being able to add code without performing a search?
Thanks

For people looking for the answer: one has to put the link on automatic. If the link is set to manual control drag will not change the file on your screen. Beware that is was created though.

Related

Xcode 8 Adding Layout Margins Crash

When I try to add layout margins to a label on a TableViewCell, using the right panel on Xcode, I try to add Explicit Margins (top, Left, Bottom, Right). But, as soon as I input a number value, or tap the arrow to change the value, Xcode crashes.
I've attached a photo to show the panel I am trying to add the layout margins in, and where it crashes.
Any ideas why it wont let me adjust the margins?
try to clear the constraints, connect/ reconnect the outlet and apply new constraints.
Had that problem. Its Xcode bug. Already fixed, so don't worry :)
I was facing similar problem.
The answer that I found and which I used in real project (but for UICollectionView) was to get the outlet of CollectionViewFlowLayout and to define the margins (line spacing and item spacing) by myself in code.
For example
collectionViewFlowLayout.minimumLineSpacing = getCollectionViewWidth() * 0.05
Where getCollectionViewWidth() is a function, that returns the size of collection view (for different screens it will be different) and 0.05 is just random coefficient.
I hope it may someway help you, you can feel free to ask anything else.
If you have crash when you add margins on any view in your storyboard you can try to get their outlets as well and to redefine their frames. It's kinda bad style, but if you won't figure out the problem its the only one I can recommend to you and which I used myself.
Also try to Clean project by clicking Product - Clean in you task bar when in X-Code.
Clear all the constraints and try from applying one by one. That way you can resolve this issue.
Please remove all the constraint applied and connected to the outlet. And Try to apply new constraints.
Some time we delete Outlet from you files .h or .m or swift file which was connected to view in Storyboard or xibs at that time this problem occurs.
Clearing all constraints is the way to go. Look around every nook and cranny and right click every little thing in both your Main.storyboard and the ViewControllerScene menu to its immediate left. If you can get the formatting back to its most base level your constraints will work fine!
Clear all the constraints and try from applying one by one.and take .xib file and connecte with Table view Cell
Xcode stores some user state information inside the Xcode project file, which is really a folder. That state information might have become corrupted. You can normally throw away everything inside your .xcodeproj folder except the project.pbxproj file. This might fix your problem.
Open up the folder containing your .xcodeproj file. Right-click the .xcodeproj file and choose Show Package Contents. Then throw away everything except the project.pbxproj file.
If you know what an Xcode workspace is, and you're actually making use of it, you might not have a project.xcworkspace file to throw away, or you might not want to throw it away. But if you don't know what an Xcode workspace is, then you're not using it so you can just throw away project.xcworkspace. Xcode will recreate it automatically.
see This Link

Text Field doesn't active for Static Cell in Table View Controller?

I have Single View App for IOS Xcode 6.4. Example Add Player screen, I tried it by myself, but Text Field doesn't active to click and typing at my application simulator (UITableViewController Static Cell) I have compared my project with example final project, everything looks good similar. How to fix this problem?
First you try with cmd+k that will open the simulator's keyboard. If that is not working then try with cmd+shit+k that may hide your keyboard but you can able to type on the text filed. If that also not work then you may accidentally off the user interaction for text field. Or may be some other view covering your text field which is transparent, so you are not able to see it. I hope that will save your problem, otherwise please provide your code sample.
There is a bug in the segue transition. Set the transition to None and it should work. I had the problem with a Curl transition.

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.

NSObject instead of the header file

I made an simple UITableViewCell. I put there image view and an label.
I'm trying to drag them to the header file and then use them.
But once I'm clicking on the tuxedo icon I'm getting an NSObject.h instead of WorkoutCell.h .
Here is a picture:
(source: gyazo.com)
I'm trying to add the label and the image view. but I'm pretty new to ios/iphone/xcode so if there is any other way to do it without dragging it (with the ctrl key ofc) to the header file. please let me know .. ;)
and yes I tried to navigate to that header file, but it doesn't appear there ..
May be your cell's class in the identity inspector is NSObject . Change it to WorkoutCell.h . Now try
In your Interface Builder you need to set the custom class of the view.
1) Click on the view in interface builder.
2) On the right pan choose the 3rd tab from the left.
3) Choose the right Custom Class.
I've seen this happen lots of times before.
If you click the third icon from the left of the tuxedo, you can navigate your project files.
From here select the folder your WorkOutCell.h is in.
Maybe someone else can provide a more comprehensive answer as to why this happens, but with this navigation you will at least be able to access your WorkOutCell.h

Xcode custom control via storyboard

I want to use a custom control in my project, specifically a horizontal picker view I found on cocoacontrols.com (http://cocoacontrols.com/platforms/ios/controls/cppickerview). I've been able to include it into my project, load data and it works very nicely.
The pickerView is setted up programatically on viewDidLoad but I'd really like to be able to use it via storyboards because I'm a using static tableView. I tried to add a UIView, set the class to the PickerView class and then set up the outlet. I builds without errors or warnings but the picker view does not appear. It only shows a white rectangle.
Anyone with experience in this? Is it possible at all or should I keep it programatically?
Thanks in advance!
Well, that's normal. CPPickerView does not seem to implement initWithCoder:... I only see an initWithFrame: in the source code, which obviously means you can only instantiate that custom UIView from code. Or you can change CPPickerView's implementation to support what you want. It's open source.

Resources