Fit UITableview within Scrollview - iphone

I created an application using a UITableview.
But when I scroll the table view, I see a white space view before and after the table view. How can I fit the UITableview so it doesn't show that empty view?
Here's an image of what happens when I scroll the UITableview.

Set the bounces property of the UITableView to FALSE.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.html%23//apple_ref/occ/cl/UIScrollView
(UITableView inherits from UIScrollView)

The answer is...
tableView.bounces=FALSE;

Related

Custom UICollectionViewLayout - Cells disappear after bounce

I've a simple UICollectionView with the CHTCollectionViewWaterfallLayout and 3 cells with a height between 300 and 400 pixels. The cells contain a view from a UIViewController which has a non-scrollable UITableView as subview.
It's all shown correctly but there is one problem. If I scroll to the bottom of the collection view on the iPhone and let them bounce one time, the last 2 visible cells disappear.
The cells are not higher than the screen of the iPhone. I also tried this in viewDidLoad:
if ([self respondsToSelector:#selector(setAutomaticallyAdjustsScrollViewInsets:)]) {
self.automaticallyAdjustsScrollViewInsets = NO;
}
It doesn't change anything. The views in the cells are inserted by code, there isn't a XIB or storyboard for the cells. If I remove the line to insert the views the cells are still visible while and after the bounce. Does this mean it's a problem inside the UITableView?
Do you have any suggestion for me?
Thank you!
EDIT: The problem also reproducible when I hide the UITableView inside the subview.

Implementing a dynamic height on UITableView

I have a UITableView embedded in a UIViewController. The TableViewCells are rows for the user to select something, so when they touch it a checkmark appears, heres where my question comes in:
I dont want the UITableView to scroll in its window, I want the TableView to grow with the items it contains. Do I need to put a scroll view on the UIViewController and then the TableView on that? Or will the ViewController scroll if the content is bigger than the View?
Also, Im not even sure where to start with changing the height dynamically of the UITableView, everywhere I look its about changing the cell heighets dynamically.
Please Help! Thank you!
self.tableView.scrollEnabled=false;
stops the scrolling
self.tableView.frame=CGRectMake(0, 0, (float)width, (float)height);
sets the size of your tableview
But I don't understand why you want to stop tableview scrolling and to scroll the whole view....

Let tableview's last cell scroll to half way up the screen

I have a tableview with custom cells. Each cell has a UITextfield. When the last cell's textfield is clicked, the keyboard pops up and covers it and the table view won't scroll up any further. Is there a property of UITableview that can be set so that the last cell can scroll to half way up the screen?
Thanks in advance
There are a two ways to approach this (that I can think about off the top of my head):
You can use the tableFooterView property of UITableView to set an arbitrary, empty view to be about half the size of your table.
You can add empty cells to the bottom of your table
Both of these approaches will accomplish roughly the same thing, but using the tableFooterView property is probably your best bet.
see Making a UITableView scroll when text field is selected for a list of solution..
Also basing your view controller from UITableViewController (since you say its a table) will provide all this functionality automatically!

Add a UIView after a UITableView but before a UITabBar?

I'm trying to add a UIView, in particular a UIImageVIew, after (that is, below, but not in a z-index sense) a UITableView but before (that is, above) a UITabBar.
You know, the typical "banner/adv space" that you can see everywhere.
My main problem btw is that i don't know exactly where to put it, as a subview of wich view specifically; the UITableView resize automatically according to the space left from the UITabBarController's main view height, minus the height of the tabbar.
I would like it to be put inside the UITableView instead of somewhere else beacuse it is more related to the content of the UITableView, but i have all the autoresizing problems of above. I've tried playing with autoresizingmask, and with the autoresizesubviews flag, but without success. I've even tried the footer ot the UITableView, but that is not fixed in position, it scrolls away if the table is long (expected, and normal).
Is there a way to add a subview in that point, stretching the table itself correctly?
Thanks everybody.
Use a normal UIViewController instead of a UITableViewController. Use the view controller's view as a container view in which you place the table view and the image view. Your view controller can still act as your table view's delegate and/or datasource.

When and where should I add a view to a UITableView's footer?

I am populating a UITableViewController's UITableView through code only. At the bottom of the table I wish to position a button that scrolls into view as the user scrolls to the bottom of the table.
When in the UITableViewController life cycle should I populate the table footer with a button? viewDidLoad?
p.s. I wish to avoid using section footers in the UITableView.
Yes, viewDidLoad is the correct place. It's not a stone-set rule though - I have change footer view in many different situations, such as after rotation in didRotateFromInterfaceOrientation.
Note that the view will be repositioned to location immediately below the last row, so if you want to provide a margin or centering for your button I suggest adding a plan UIVIew as footer, and then add your button(s) into that UIView.
Yes, put it in viewDidLoad. Here is some sample code.
You can just set the tableFooterView property of a UITableView to your button.