Outlet/Action problems in Xcode 5 - iphone

I've searched for a few hours to try and figure out the answer, but haven't as of yet.
On creating an outlet/action for an iOS app in Xcode 5:
I'm trying to create an outlet (by CTRL-dragging) from a label in Main.storyboard to ViewController.h (which I had to manually select in the Assistant Editor because only UIViewController.h shows up under "automatic")
No "outlet/connection/action" menu shows up when I drag. However, a menu does show up if I try to drag to the UIViewController.h file. (It just then tells me UIViewController.h is locked, and I can't unlock it)
I've also tried putting "ViewController.h" into the custom class part, as that seemed to work for some other askers out there.
I believe it may (?) have something to do with ViewController.h not showing up under "Automatic" in Assistant Editor. I have tried creating an outlet with a different project and that seems to work, and ViewController.h shows up under automatic.
I'd like to have posted a screenshot but I need 10 reputation. Anyway, thanks in advance for your help!

You need to set the Custom Class in the storyboard to a class that you have written that subclasses UIViewController.

Make sure that the scene you are using is under the UIViewController class that you intend on using it with.
Here is how:
Select Scene (click black bar underneath || ctrl+shft+click || Document Oultine)
Select Identity Inspector
Enter UIViewController class of interest under Custom Class

Related

"No #implementation found for the class" error in Storyboard in Swift

I'm trying to create in IBOutlet in Swift using my Storyboard and assistant editor, but I'm receiving a strange error I've never seen before. Looks Objective-C-ish.
I navigated to my ViewController's Save button in my Storyboard
Then I control-click dragged the Save UIButton to Xcode's assistant editor to make the IBOutlet. I get the error "Could not insert new outlet connection: No #implementation found for the class "ClassBVC". How do I avoid this error so I can make the outlet and an action?
I noticed when I click the button with the four squares before "Manual" and the < > buttons, I can go to "Counterparts" and there's a "ClassBVC" file with the same name, but with "(Interface)" next to it. It's not the file that I need though. Even when trying to create an outlet there, I get the same error.
I had same problem. rebuilding works for me.
Try closing Xcode and opening it again.
Creating one #IBOutlet directly in the view controller, and then creating the reference to the component in the Outlet Section in .storyboard worked for me. After that, I was able to drag the components normally to their respective view controller.

Add SDNestedTable to a subview

Hello there fellow programmers,
I am wondering how to add the SDNestedTable into a project of mine.
Here is the source code for the SDNestedTable:
https://github.com/serverdensity/ios-SDNestedTable
I would like to add this table to a subview of one of my XIB's in my project.
Thanks, hopefully someone can help me out! :)
If you add a UITableView to your XIB file, then click on the second tab (right side panel) and in that make the class the SDNestedTable rather than your UITableView so it makes it that class instead, assuming also that SDNestedTable is a subclass of UITableViewController.
You should be able to then add your property to your .h file and attach it in your XIB:
#property(nonatomic, weak)IBOutlet SDNestedTable *nestedTable;
and in your .m file will go all the delegate methods you need that are also listed at the bottom of the github link you've provided, similarly to a UITableView and the dataSource and delegate methods they have I would imagine.
There are three problems (based upon the review of your actual source code that you posted in your other question):
You need to make sure you include the NIBs and PNG files in your "Copy Bundle Resources";
If you are going to support iOS 6, there is a bug in SDNestedTable and you have to change the cellIndexPath of SDGroupCell from assign to retain;
If you're adding the SDNestedTable (with its own controller) as a subview of SDNestedTableController as a subview, then you should use view controller containment.
All of this is explained in greater detail in my other answer to this question:
Works on iOS Simulator but not on iPhone

Where is the main viewcontroller that is displayed in your iPhone app specified and told to become visible?

I'm working on an iPhone app again and I'd like to setup one view to be seen before another. I've added the view to my window and have specified the viewcontroller code that I'd like to use, but I can't find where on earth xcode specifies which viewcontroller in the window is displayed first. I'm sure it must be something obvious. I thought that the appdelegate seemed logical, but I don't see it displayed there. Any help? :(
Usually it is in the UIApplication setup code. Also try looking in your xib file as to the linkages setup there!!!
Without seeing more code or your setup, this is the best I can do!!!
As you can open the MainWindow.xib file you can see the part on the windows that specifies that from which viewcontroller it is gona load. (Like "Loaded From "RootViewController""). From the inspector of the window there is an option called NIB Name that gives you a list of view controllers available in your project.Changing these will change the setting of from which view controller you want to begin your app.
Hope this will help you.

Moving text fields for keyboard with TPKeyboardAvoidingScrollView not working

I have a TabBar app with one of its tabs embedded in a NavigationController. This particular view is a form with text fields on it. I want to us the TPKeyboardAvoidingScrollView to move the UITextFields up when the keyboard moves into view. I have followed the instructions on the Github page but it just does not work at all.
This is what I have done as per the instructions:
Added the TPKeyboardAvoidingScrollView.h and .m to my project
Added a UIScrollView to the view on the storyboard (Xcode 4.3.1)
Selected the ScrollView and in the inspector changed its class to TPKeyboardAvoidingScrollView
Moved all my textfields into the UIScrollView
This did not work... So looking at the sample code I tried adding a few more things:
In my view controllers .h file I added:
#class TPKeyboardAvoidingScrollView;
and linked the ScrollView resulting in this line of code being added:
#property (weak, nonatomic) IBOutlet TPKeyboardAvoidingScrollView *scrollView;
Imported the TPKeyboardAvoidingScrollView.h into my controllers .m file.
But still the drop-in code that everybody else seems to praise just does not work for me.
Can anyone point out my incompetence please?
Thanks in advance for any assistance you may be able to provide...
I ran into this exact problem when trying to use this class as well and spent wasted a good deal of time on something that is supposed to be a time-saver.
I set breakpoints inside the TPKeyboardAvoidingScrollView and noticed that none of them were ever hit. After trying several things I noticed some output in the debug window:
“Unknown class TPKeyboardAvoidingScrollView in Interface Builder file” error at runtime
I found some helpful information in this thread. Basically it seemed that the file was being optimized out because it was never actually being used in the code anywhere.
In order to get it working again I did a couple things, any or all of which may be necessary:
Click on the TPKeyboardAvoidingScrollView classes in the project outline. Reveal the Utilities panel on the right side in Xcode if you have it hidden and confirm that the files actually have some target membership or they will not be built.
Delete the app from the device or simulator you are testing on so you get a fresh load.
Rebuild the project and load onto the device/simulator. The error should be gone, you should be able to hit breakpoints in the TPKeyboardAvoidingScrollView classes and it should all work now.
As an alternative you might want to look into the solution provided here by jhoule. The gist is that you add a call:
[TPKeyboardAvoidingScrollView class];
to your app delegate or elsewhere in your code to ensure that the code gets referenced and is not optimized out.
Hope that helps.
what you have to do is go to the main storyboard and add missing constraints of the scroll view or you can click on the scroll view on the storyboard and go to editor on top of the menu of xcode and go to resolve autolayout issues and click on reset to suggested constraints.run the project.Good luck.

Connecting outlets in Window Based App, Objective-C

I'm reading through a beginners iPhone text book and just finished writing all the code for a route tracker app that uses Map Kit and Core Location. I have the app running with no errors on my iphone 4 device but when I tried interacting I realized that none of my IBOutlets were connected to anything. When I referenced the beginning of the tutorial in the text, all it says is to "connect the appropriate outlets".
Here's why this usually simple task has me confused. The tutorial says to create a Window Based Project, so there is no ViewController. Then, in Interface Builder, the view is built in MainWindow.xib. The only IBOutlets of the project are located in Controller.h / Controller.m files that you create and which contain mostly all of the code for the app.
I usually ctrl-drag from File's Owner to the UI in Interface Builder, but in this project there seems to be no way for me to access the IBOutlets in Controller.h / .m from the MainWindow.xib file.
I'm frustrated because it seems like this should be such an easy fix but I'm totally stumped.. any help is really appreciated. Thanks
As I see it, you have two choices:
Add the outlets to the app delegate. This is probably not the best plan.
Put an instance of your controller class in the .xib file.
I think option 2 is what you want. If you check the Controllers section of the library, you'll see a component called "Object". Drag one of those into your xib, then inspect it. Select the info pane in the inspector (the circle with a white i in it) and change the Class to the name of your controller class.