Question

I have a beginner iPhone project going. I have a TableView, which is just a listbox with a bunch of entries and a small UiView on the bottom. See the pic.

The problem is that the UiView essentially becomes part of the listbox and will only appear when I scroll down to the last item in the TableView.

I'd like the UiView to be anchored on the bottom and never move. I've looked all around the Interface Builder and can't find anything (though in its defence I am a total noob to iPhone dev). How do I accomplish a trick like this?

alt text http://www.sqleffects.com/mystuff/ibissue.jpg

Was it helpful?

Solution 4

The bottom line is this: if you create your project based on the Navigation template, you can't resize the UiTableView, period.

So to do what I want, I basically have to start from scratch and pick a View or Window based template and drop the UiTableView on it manually.

OTHER TIPS

Ok, what you need is a UIView, that contains

  1. an UIView, which acts as the TableViewController and thus has to implement the UITableViewDelegate and UITableViewDataSource protocols (but it MUST NOT be derived from UITableViewController directly, since by doing so the UITableView will automatically take up the whole screen size (except toolbars, navbars and/or tabbars))
  2. another UIView, the one you would like to place at the bottom

by doing so, you can create an UITableView in IB (not an UITableViewController!) and connect it with the UITableView property in your UIView (the one mentioned in 1.)

using this method it is possible to give the UITableView a fixed size (which you'll need to, to have room at the bottom for your second UIView)

To build off gabtub's answer, the UIView containing your table view and your bottom view doesn't need to implement the UITableViewDelegate and UITableViewDataSource methods.

Since it sounds like you're building with a view controller, I'd make your main view controller a subclass of UIViewController (instead of using UITableViewController). You could then add your UITableView and your UIView the the UIViewController's view instance.

I'd then make your UIViewController subclass implement the UITableViewDelegate and UITableViewDataSource protocols - you'll end up with something that looks similar (code-wise) to your old UITableViewController subclass, but it's view property will be the underlying UIView instead of UITableView instance (if you poke around in the debugger, you can see the [UITableViewController view] and [UITableViewController tableView] return the same object)

One of the advantages over gabtub's suggestion is it saves you from creating a one-off UIView subclass, since you've probably already got a one-off UIViewController subclass (or, previously had a one-off UITableViewController subclass).

The problem is probably, that right now, the UIView is a section footer view, and is therefore contained within the table view.

If you delete the UIView from the TableView, scale the TableView to make space for the UIView and a bit more and put your UIView where you want it, it probably will be added to the TableView's superview. You can then resize the TableView to the correct size.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top