NSObject instead of the header file - ios

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

Related

Can you add a custom button to the Utilities Panel in Xcode?

Just wondering if it's possible to add a custom button to the Utilities Panel in Xcode that you can drag it into a storyboard scene and have certain aspects already set, color, font/size, gradient etc.?
You are describing a custom xib file containing a view and its subviews. You then load the xib and stick the view in your interface in code, wherever and whenever you need it. Okay, you won't be able to see the effects of that within the storyboard, but it solves the problem extremely neatly.
Another possibility, if this is just about a button and nothing else, would be a UIButton subclass where the button configures itself to have the features you want.
But there is no way to drag-and-drop a custom button from the Object library into the design canvas. What's in the Object library is what's in the Object library and you can't change that.

Navigation Bar Item Image is not visible

I trying to implement a hamburger menu using a scroll view, two container views and two embedded views with Swift 2 and Xcode 7. Everything works but for some reason, I can't see the picture of the Navigation Item I set. However if I click on the area where the Item is supposed to be it responds as I expect. But I can't figure out why I can see the Nav bar item image?
Any idea what I am doing wrong?
Thanks
Be sure that the image that you're trying to set is added to your project. Not the project folder but the actual Xcode project and used in the target that you're currently using.
My guess is that you're setting the image with
UIImage(named:"YourImageName")
Also, another hint is that you can make your button visible.
Hope this helps.
I figured out my bug. I had copy a piece of code to create the menu image and paste it in a class with the same name. So the image was never created. But Xcode didn't complained that I have a nested class of the same name as the main class, that would have helped so much :-/

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 want to change name of the view in the IB. Please see the screenshot

I want to rename View to View1. How can I do this?
Not sure what you are planning to do. If you want to have this view renamed in IB objects inspector:
Select the view
open right panel
go to the Identity Inspector(3rd icon)
fill Identity->Label (with placeholder "Xcode Specific Label").
However, if you want to access the view from view controller(use it in code), you should read about IBOutlets.
in the identity inspector, there's a section called "Identity". in that section is a textfield for "Label". changing that will change the name that appears in xcode. note that this is only something that has effect in xcode - it doesn't change anything about how the view is used in the app. is that what you want?
I think the operator wants to change the name in the outline. This can be done as described but it is no longer under Identity but Document.

Why storyboard constraints are changed automatically?

Friends my project is in ending state ,but even in my backup all constraints are changed i,don't know how and why ,but if i run all is available but in storyboard can't see any thing.
it is storyboard image :
it is simulator image :
how i have to solve this ,i need my previous constraints how its changed automatically ?
No issues, you can get your storyboard clean and restored.
Goto your storyboard, select the particular view controller/ table view controller.
Choose the file inspector on the right side, goto Interface Builder Document section uncheck Use Size Classes
Proceed by choosing Disable Size Classes option from the dialog popup. Find that all your views have been visible now, and there is the possibility of constraint warnings.
Click on the yellow mark to the right side of your view controller, update the constraints one by one.
At the end, your previous viewcontroller/tableviewcontroller state is restored.
If you have more than one viewcontroller/tableviewcontroller has this problem, do the above steps for all.
Note: Don't forget to check the Use Size Classes back.
Happy coding :)

Resources