How to connect UITableView to new created UITableView class? - ios

This is a very simple question. I was following a very basic youtube video but a little bit in different way. I have a UIViewController. There is a button on that called "History". When I press history I need to open a table view and show the history. Step I did is:
Drag and Drop a UITableViewController
Create a new file which is UITableViewController
So I have UITableViewController.h and UITableViewController.m file
Now I want to connect this UITableView to this new class and implement it. In the video said I must press Ctrl and drop in on the .h file to create an IBoulet
After pressing connect this must appear
#property (strong, nonatomic) IBOutlet UITableView *tableView;
But in my xcode when I drag and take it to the .h file there is no plus sign to connect them together.

select your table view in interface builder. And at the right side of screen you will see object inspector menu. Write your custom class name here (like DinButton)

select table and then go to identity inspector in the right side of the xCode. (left to the Attribute inspector)
Then add your class name in the field "Class".
Thats it.

Related

Unable to Set Referencing Outlet

I am unable to set a referencing outlet for a text field I have created. I am trying to do this via Ctrl-Drag. Can anyone advise? I have set the delegate as the View Controller. In general, I only have one view which is populated with a few text fields and I have written the following code for the ViewController.h which is what I'm trying to set up as a Referencing Outlet:
#property (weak, nonatomic) IBOutlet UITextField *userIDText;
First, make sure the control you're dragging from is the same class as the outlet (in this case, UITextField) or it could be a subclass of that class.
Second, make sure control's parent view is a subclass of the file you're dragging to.
Third, make sure the file you're dragging to is saved. This is the most common problem I run into. Go to the source file you're dragging to and push Cmd+S to save.
Fourth, when in doubt, Cmd+Shift+K to clean, Cmd+B to build, then try again. If that still doesn't work, restart Xcode. And if it's still not working, go back through the checklist.
In my case, to be able to create a referencing outlet,
I had to open the Storyboard.
Click on the top View Controller element (left panel in the Storyboard)
In the Identity Inspector (right panel), I had to select from the list my custom view controller class before I could drag and create the referencing outlet in it.
In my cace,(swift3)
1.right click on the storyboard.
2.Ctrl-Drag from black window and ReferencingOutlet to View on the storyboard.
enter image description here

I can't create an outlet in Xcode 5

I am trying to link a create an IBOutlet for a UIWebView Element, however whenever I hold down control and drag from the Storyboard to the ViewController.h file, nothing happens and an outlet is not created. I already have an outlet in this file, however, I would like to create another one. Whenever I go to the view controller for the previous outlet and hold control and drag the element to the ViewController.h file a new outlet is created. Is there a setting that I have enabled that stops this shortcut from working. Is there another way to create an outlet for ios in Xcode 5.0.1 on Mac OSX 10?
Fixed issue. The class of the view controller was UIViewController not ViewController. This meant that the ViewController.h and .m files were not showing up under Automatic. Once changed I could view the ViewController.h and .m files and create outlets in them.
I recommend not using storyboard, while it is a lot easier to use, it doesn't let you do many things. To create a new outlet, go to where you want to create it (this will most likely be a header file) and then type: IBOutlet yourOutletType *yourOutletName so to create a UIWebView you would type:
IBOutlet UIWebView *myWebView
and to create an outlet, such as a UIImageView, you could type
IBOutlet UIImageView *imageView
just remember to hook it up in your .storyboard file.
Again, I recommend not using storyboard, it IS a lot easier, yet it really has lots of limitations

UIPickerView is not being dragged onto header file

I keep trying to use CTRL-Drag from the uipickerview to the ViewController.h but its not creating the object definition in the header file. What do I do?
Make sure that in your xib/storyboard you have set the correct class in the identity inspector. From the drop-down menu, choose the correct subclass that you have created for your view.

How do I add a custom class to a storyboard?

I am currently trying to implement a custom radio button class that I have been messing with (located at https://github.com/t4ku/RadioButtonWithUIKit). This radio button solution draws everything programmatically.
I was wondering if there is a similar solution using buttons that were added via Storyboard. I already have my design exactly how I want it through Storyboard and would much rather somehow "link" the buttons with my radio button class.
Any newer ideas or suggestions would be greatly appreciated.
You can change the class of an object on Storyboard in the identity inspector (you can manually enter the class instead of relying on the drop down menu). You can then link the object however you like.
If Storyboard doesnt accept the RadioButton class for some reason you could also create a custom class of UIButton that would inherit from the RadioButton class and then use that in the same way.
That control is based on UIView, so in your storyboard just add a new View object, select it, and then set the class (at the top of the image) to RadioButton:
You won't be able to see anything but a blank view where you place it, but it will work properly when you launch the application. This will at least make it easier to resize, position, etc.
If I understand your question right, to refer to a button added to a storyboard programmatically, you have to link the variable name in your .h file to the actual button in your .xib file. If you add the following line to your .h file
#property (nonatomic) IBOutlet UIButton *theButton;
Then when you return to the .xib, there should a yellow cube (file's owner) to the left of the storyboard panel. If you right click on that cube, you should get a list of outlets. At the end of the line that has your button's name, there should a circle. If you Ctrl+Click and Hold and drag it to the button in the storyboard, it should like the variable in the .h file to the button in the storyboard.
So now when you refer to the variable name you created, you will be referring to the button in the storyboard.

It won't allow me to create an outlet

I've got a Table View Controller object in my Storyboard, but I've made it a custom class called StaticDetailViewController, which I created as a subclass of UITableViewController.
However, when I go to drag from the view to the .h file in the Assistant view, no connection option appears. Why is this?
You have to open and close your curly braces for your #interface in the .h file. For some reason it won't let you control drag using the assistant editor unless you do so... (screenshot)

Resources