IKImageView Causes App to Crash - objective-c

I am new to ObjC. Thanks in advance for your help and patience!
I'm trying to add an image to a window in my app (This is OSX, not iOS). I added an Image View (IKImageView) via interface builder to the window. I then added my image to the XCode Project and assigned it to the view.
When I try to compile the app it crashes with the error: "cannot decode object of class (IKImageView)".
The moment I delete the IKImageView it compiles just fine.
My initial thought was that I wasn't importing the required file, but this appears to be a subclass of NSView, so that shouldn't be the problem.
Any thoughts as to what I'm doing wrong?

Select the project on the left side of Xcode.
You will see the "summary" tab on the right side. Select it.
Add Quartz.framework into "Linked Frameworks and Libraries".

Related

Controller View Getting wrong position

I have application with Objective C which is developed for ios9 devices, when am trying to run the same code in xcode 8 am getting wrong position of my navigation bar,
Am using viewcontroller as a XIB and am converting into navigation controller in appdelegate class. is any one met this issue
You can try following solution:
Select your Xib file of viewController.
On the right side, navigate to the File Inspector tab.
Change the value for "Build for" to "iOS 7.0 and Later" or any other iOS version and later.
Clean, Rebuild and Run project.

Xcode, can't find my class which I had created

I'm playing arround with Xcode (for iOS) and added a View Controller to my Storyboard. Now I've created a Class (File -> New File -> Objective-c Class) and made that a subclass of UIViewController. Now the .h and .m files are generated and listed on the left side in Xcode, but when I want to change the "custom class" of my added View Controller there is nowhere my class which I had generated. Am I doing something wrong?
Thanks in advance.
I've had the same problem. Quitting and opening Xcode will make the Class show up in the list.
edit: I've also recently found pasting the Class name will work in 5.02 Xcode.
I had the same problem. But I discovered that I was clicking inside the "window of storyboard" and was selecting a view, so with no viewController related to. My solution was: to click inside the owner, or the viewController from the left list, and then change the custom class.
There are multiple reasons and solutions....
#1
Select project icon in "Project Navigator".
Then go to your Target's Build Phases -> Compile Sources.
Finlly, click the + button, and add your *.m or *.swift file.
#2
In one case, the same file was added multiple times to project:
Remove all instance of the file.
Add file back to project (once).
Finally, select the file in "Project Navigator", and in the "File inspector" on the right, look at the "Target Membership" section. The app target (not the Test target) should be checked, similar to this:
#3
ANOTHER WAY IS
Save all my work;
Just quit Xcode & load it again;
Then I was able to insert the new outlet connection successfully.
#4
Close the project you are working on with.
Delete the【DerivedData】folder of you project.
Said folder may be:
Inside your project's folder,
Or, inside ~/Library/Developer/XCode/DerivedData/(your project)/
Or, somewhere else that was setup by you.
Restart you project.
#5
Simply Clean your Project,
Then Build Again,
Finally, check and/or run.
I'm not sure what you mean by " but when I want to change the "custom class" of my added View Controller there is nowhere my class which I had generated ". It seems like you are trying to make the UIViewController in your storyboard to be of the same type of your custom UIViewController subclass.
If that's the case, then select your UIViewController (make sure you're not selecting the UIView within that UIViewController)
With the UIViewController selected, open the right hand view and open the Custom Class tab, then start typing in the name of your UIViewController subclass.
If that isn't working, then you need to ensure that the in the .h file you say:
#interface MyCustomUIViewController : UIViewController
If it still isn't working, ensure that in storyboard you are selecting the UIViewController that you put down. If you are trying to fill in the Custom Class of a UIView with a UIViewController subclass, it shall not work!
If it all still doesn't work, try COMMAND+SHIFT+K, and COMMAND+B to Clean and Build!
Good luck.
Just a quick advice in case you are about to give up: Do check that the item you have in the storyboard is compatible with the custom class you created that you are trying to assign. For example, you cant choose a UIView based class if you have a UIImageView as a component in your storyboard. In that case, it simply wont appear in the dropdown list.
You don't have to completely quit Xcode. Just close all your Storyboard tabs completely and reopen a new tab by double clicking on it.
Solution for my situation - just close all other xCode windows (i got opened few projects at same time).
Also sometimes help cleaning of project.

using a storyboard from another project

I am working on an Iphone Application, and I want to get a storyboard from another project.
I added the storyboard and all the viewcontrollers and images to my project (I copy Paste them from the other project)
Then I set it as the main storyboard in the info,plist file.
I get no compile errors or warnings however if I try to run the project I get a signal SIGABRT error.
(If i return to my original storyboard the app runs normally)
Any idea what might be causing the problem?
Thanks a lot for any help
Have you wired all storyboard object to proper ViewController ?
I often forget wiring delegate =)
In the summary tab make sure that the main storyboard is selected under "project name"/summery/ iPhone/iPod deployment info

Ctrl-Drag from button to method not working. Xcode/Interface Builder

I am building an iOS app and i have most of the code/GUI built (its a single view app). Now i have the .xib and controller.h file next to each other and I want to associate a button click with a certain action. Everytime I try nothing happens. The UI indictor that I am dragging shows up but it wont let me connect to the method. This happens for all the objects/methods.
I have an almost identical project that works just fine too!
Select your XIB file and then select "Files Owner" which is the yellow cube.
In the Utilities Sidebar, select the Icon with the circle and arrow inside of it (which is the "Connections Inspector").
You can then Control + Drag your to your button.
//// Edit ////
After investigating your project...
Pretty sure you deleted a storyboard and then added a .xib but didn't set it's class, or link it's view as an outlet.
To do that:
Select the new view (XIB), then selct the main view, and in the identity inspector, set it's class to your custom class name "AVYSViewController."
Switch to the connections inspector and Control + Drag the "view" outlet to the main view in your XIB.
Also, your project was looking for the MainStoryBoard.storyboard file. So get rid of that setting by selecting your project, then selecting your target, and in the "Summary" tab, delete anything in the "Main Storyboard" field.
Note: I checked to see if your project settings were valid before I deleted the storyboard setting and it returned NO errors, so beware of this problem for future projects.
I think i'm reading the same book as you (Big Nerd Ranch's "iOS Programming"). If so then yeah, I had the same issue as you. Admittedly I am using my laptop to vnc through to a mac box to work on xcode, so I thought it was vnc not capturing the keyboard properly, but turns out it wasn't vnc as I could right-click/cntl-click drag on other things.
Admittedly again I didn't do much research on why it wasn't working, but in the meantime I just right-clicked on the button, which shows the events that the button emits, then click-dragged the "Touch Up Inside" event and dropped it on the controller/owner, which then displayed the actions/methods to hook the event to. If you look on page 17 (if you are reading the same book) then that is the event that was hooked up.
Sorry if there are any obvious glaring errors with what I just say, have only just started reading this book today after a big lunch.
I think you should rephrase you question.. It's very confusing. But if i understand what you are saying, you now have the files open side-by-side in the using the assistant editor. The Xib file on the left hand side, the .h file on the right. correct?
Now you are trying to link the event in the control, to the method you have defined in the .h file. right?
So if you are in fact seeing the methods in the .h file that you want to link to, but the editor is not letting you link to it, then chances are that you have have the xib file side-by-side with the wrong .h file. Are you sure that the .xib file and the .h that are side-by-side are both called controller ? controller.h and controller.xib ?

How do you get a custom object to show up in the Interface Builder object palette?

I have been trying to create a custom object and have it appear in the object palette so I can drag and drop it into the .xib file when I am building an iOS app. I cannot find any tutorials or instructions online on how to do this; did Apple remove this functionality? Any help would be greatly appreciated.
You can't add custom plugins when using the iOS platform. This is possible for normal MacOS development but sadly not for iOS. If however you have a UIView descendent for example, drag a normal UIView onto the screen and change the class to your custom class to use it HOWEVER you will get no design-time view of the custom control.... :(