Iphone : what do I need to do to a nib file to an exisitng object - objective-c

I have tried using an outlet to connect my tableview controller to my object, setting the nib name in IB and setting the class in IB but it still wont link? I know this as im trying to set my table view to 'grouped'
Thanks very much.

It's a little unclear what the problem is. Do you have the outlet visible in IB, but it's not letting you draw a little line to the table view? In that case, double check the class of the outlet. It should be the same (or a superclass of) what you're trying to hook up to it.

Related

Cannot assign UITableview in xib to custom tableviewcontroller

I know this problem has been tackled quite a lot over there but I stil cannot find a solution in this case.
Basically, I have a tableviewcontroller called "TableViewController" that inherits for some reason from another class called "BaseTableViewController" (which inherits from UITableViewController). Everything works fine when I initialize an instance of TableViewController. I have my tableview in full screen.
Because I added a searchbar (which is working) and needed more room for other elements to be displayed, I want to insert this table view inside a UIView. I created an other UIViewController ("MainView") with a xib file and I added a tableview object as a subview.
My problem is I don't know how I can assign this tableview to my custom class I was using before ("TableViewController"). I tired to import the header file (TableViewController.h) in the header file of MainView.h but it does not seem to solve the problem.
Would anyone have an idea how I could link the tableview inside a UIView to a custom tableviewcontroller?
Thanks!
If it can help, below is my mainview with a tableview object I would like to be linked to my custom tableviewcontroller in order to have it with my datasource, delegate, search bar, etc. I cannot insert "tableViewController" in the custom class.

iOS: UIView directly implementing a Nib

Sorry if this has an obvious answer, I can't seem to find anything describing this situation. How can I set up a nib file which directly implements a custom UIView? In other words, the top-level view in the nib file becomes an instance of my custom UIView class? The closest I've been able to find so far is to create a custom UIView which loads the nib and sets it's top-level view to a UIView* property (and all it's subviews to the appropriate outlets by loading with owner:self). This works, but as I understand the top-level View does nothing except act as a container for all the other views - which is what my custom UIView is supposed to do. Any suggestions?
Edit: I got this in the end: the issue is my custom view class was set as the File's Owner class, when it should have been set as the top-level View's class. I didn't know it was possible to set outlets on elements in the IB as well as the Owner. Setting the Owner to the class of the ViewController that will hold it and the top-level view to my custom view has it all working.
If you create a project using the single view template, you will get an empty view. If you add a class that is a subclass of UIView, you can change the class of that view in IB to your class (in the identity inspector).
If I have understood your question correctly, then this should help -
In the IB, on the right-pane. select the "custom class" dropdown & fill in your custom UIView class. The image shows UITableViewCell instead of that put your custom UIView class name.
Correct me if I have not understood your question correctly.

IBOutlet UIViews are null?

I have a class called ActorController and it has a NIB file. I have created IBOutlets in ActorController.h that match up with various UIViews and UIImageViews in the NIB file. However, these views never show up on the screen like they should. Upon further investigation, I have discovered that if i use NSLog to print the UIView object to the console, it prints null. Could anybody suggest what I may be doing wrong? Any help is appreciated.
Some things to look for:
Nib not loading at all:
wrong name
nib file not included in project
capitalization problems (iOS is case-sensitive on the device)
outlets not connected (views should still show up on screen, though)
outlets connected, but to wrong object
view controller created and initialized properly, but not displayed
active view controller is not the one you initialized from the nib

NSViewController and bindings

In my application I have a single nib file. The File's Owner is a NSViewController and insider there is just a vertical slider that I want to bind to a property in one of my classes. (I don't have any other nib files since it is a status bar application, so I don't have a window). The nib is loaded runtime to create a custom view for a NSMenuItem.
The problem is that I want to use an object controller to do the binding but I'm not sure what is the content of the object controller. How can I access from the nib to an arbitrary class in my project?
In the examples I have seen, usually the object controller uses the File's Owner to access the class (and the property for the binding) setting the Content Object binding to the File's Owner. But in my case from the File's Owner I do not have access to the class.
Any pointer?
Ok this works for me. It is enough subclassing NSViewController and sets the new subclass as the File's Owner. Now it is possible to use a Controller Object to bind through the File's Owner.
If you use XCode 4 you can Control-drag from the slider to the .h file (AppController.h?), and you will get the option to generate an outlet or an action. If you want to create an action, caused by sliding the slider, you should select action. The generated method will be called whenever the slider is changed. If you want the slider value to react to an event (or a changed instance variable in your program), set it to 'outlet'.
Hope that helps, let me know if you were really looking for something else :-)

Find a UITableView from code?

How do I connect a UITableView so I can find it in my code?
you'll need to add what is called an outlet. I prefer to not use IB for my apps as there's less hocus pokus but if you do prefer to use interface Builder you'll need to read up on a few tutorials. There's a few here:
http://monotouch.net/Tutorials
The main steps (from memory) are:
add the tableview to your view
add an outlet to the parent view using the object explorer classes view
connect the tableview to the outlet using the connections view
save and exit IB
go back to MT and you'll be able to access the tableview using the name of the outlet you defined
here is a helo world tutorial using IB: http://monotouch.net/Tutorials/MonoDevelop_HelloWorld
hth :)
w://