Change TableView Size When It has AN XIB - ios

My UITableViewController class uses an .xib. I would like to make the TableView only take up half the size of the screen, so that I could add more to it. Is there anyway to do this, or do I need to create it all in code, and not use .xib.

This thread covers a similar situation. In practice it would be easier to use a standard UIViewController and implement the UITableViewDataSource and Delegate methods manually.

you cannot resize the UITableViewController class,if you want to add something under table place it at it's footer.
You Can also declare UITableView in UIViewController through XIB through which you can resize it.
in .h File
IBOutlet UITableView *tView;
and connect it to file owner
Thanks

Related

What does one gain from using a UITableViewController?

Why not use a UIViewController with a TableView embedded in it?
UITableViewController has three properties:
tableView;
clearsSelectionOnViewWillAppear;
refreshControl.
Also, you can create Static Cells in Interface Builder only in UITableViewController.
If you need anything from above - use it instead of UIViewController subclass.
UITableViewController is a "shortcut" that is useful in situations when you need a simple table with static data, archived in a NIB/Storyboard. Using UITableViewController lets you get most of the behavior for free, without the need to write and manage a special data source for it.
Other than that situation, UITableViewController gives you very little on top of UIViewController with an embedded UITableView.

UITableViewController with Storyboard

I have a subclass of UITableViewController.
I overrid initWithCoder so that when the controller initializes it adds five items to the UITableView that it creates by default (I did not create a UITableView in IB because the UITableViewController creates one).
I would like to add a header (with 2 buttons) that I created in Interface Builder to that tableview.
I linked an IBOutlet to the header from Interface Builder and I set it to be the header of the UITableView created at initialization.
The problem is that although I did this I only see the UITableView with the 5 items (displayed corectly) but I don't see the header. It's like it ignores the header from the Storyboard or something like that.
Any idea why?
Thanks.
I just captured one GIF from of my example StoryBoard that you can drag UIView on top of your UItableViewController and make it resize as par your need. pelase check following.
Hope that help to you. After drag view on UITableview you just need to create IBOutlet and make your task complete :D
Drag a uiwebview into right above the tableview's first cell.

iOS - Having 2 table views and other elements under one TableViewController

I'm trying to make an interface like this one:
But I get the following error in XCode: Illegal Configuration: Static table views are only valid when embedded in UITableViewController instances
That controller is a subclass of UITableViewController, so I don't really understand what the problem is, any insight?
First of all, I think you're saying that ProfileViewController is a subclass of UITableViewController. If that is the case, the top level view should be a UITableView not just a UIView. And the error does make sense. If you want to create a static table view, it needs to be embedded in it's own UITableViewController, which is what you get when you drag a UITableViewController from the Palette to the storyboard.
Amended to answer question in comments
So starting from scratch. Drag a TableViewController onto your storyboard and change the class to ProfileViewController. That gives you your tableview with the prototype cells. Then drag an empty view to near the top of the TableView. This will add a headerview to the tableView. (Every tableview has a subview for a header and a footer. This is different than the section headers). Now make that header view taller and drag your other elements into it: the segmentedButton, the search field. Drag your UIImage View. then drag another tableview and position it next to the image view.
Now create a subclass of NSObject NOT NSTableViewController like so.
#interface MiniTableViewController : NSObject <UITableViewDelegate, UITableViewDataSource>
And put the datasource and delegate methods for that minitableview in there. Back on the story board, drag an object to the hierarchy change the class to your MiniTableViewController, and connect the delegate and datasource outlets from your minitableview to the MiniTableViewController in the hierarchy. Make sure you're using the assistant view. Then ctrl-drag from the MiniTableViewController object to the ProfileViewController.h (right before #end) and create an IBOutlet. Now you can access your new custom object from ProfileViewController. You can also create an IBOutlet in MiniTableViewController and connect it to ProfileViewController if you need MiniTableViewController to send messages to ProfileViewController.
A UITableViewController can only have one Table View. You have two. You have to find another way to do it.
Have you put a UITableView in your xib ?
If yes, have you bind this UITableView to your controller?

IB - add UIView to UITableViewController?

I like to accomplish an UIToolbar below an UITableView and I wanted to use the UITableViewController because it sets up the data source and delegate and other stuff on its own.
I don't need an UINavigationController as has been proposed in similar topics due to only having 1 view currently and my data is without a hierarchy.
I didn't manage to drag and drop an UIView or UIToolbar to my UITableViewController at any place (scene design area or view hierarchy) in Interface Builder of XCode 4.2.
Thus my question: How to add an UIView to an UITableViewController in Interface Builder?
I did manage to achieve the look I intend to accomplish using an UIViewController with an UITableView and an UIToolbar contained in its UIView.
Would using an UIViewController with an UITableView be much more involved than relying on the UITableViewController?
Thank you for your time!
I think this is your real question
Would using an UIViewController with an UITableView be much more
involved than relying on the UITableViewController?
The answer is no, its not much more work. Just add this to the viewcontrollers' .h
#interface MyViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
Then in the .h add the datasource and delegate functions( you could just copy and paste the functions your'e currently using in your TableViewController)
NOTE: From Xcode 4.5.1: "Static table views are only valid when embedded in UITableViewController instances."

Insert UITableViewController into Other UIView

I've got a UITableViewController that inserts custom UITableViewCells into a UITableView. Is there a way that I can put this UITableController/View combo into different views? I've got the behavior of the UITableView acting the way I want, I just want to use that UITableView in different UIViews (say a UIView with a UILabel above the UITableView and one with a UILabel below the UITableView).
I know I can make a UIViewController that has an embedded UITableView in it and have the UIViewController act as the UITableView's delegate, but then I would have code reuse (the UITableViewController logic would be in multiple UIViewControllers). Or am I looking at this problem the wrong way?
I want to somehow reuse the functionality of my UITableView in different UIViews.
Thanks
Yes, you can, simply instantiate (or get a reference to) the UITableViewController inside the UIViewController and call something like this:
[self.view addSubview:tableViewController.tableView];

Resources