Implementing a dynamic height on UITableView - iphone

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....

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.

How to interact with a UITableView displayed overlapping another UITableView

I have one UITableView displaying some data, and when the user begins typing in a UITextField above the UITableView, another UITableView is displayed below the UITextField to show suggestions. This "suggestions" UITableView overlaps the UITableView below the UITextField. Tapping on one of the suggestions will populate the text box with the item tapped.
The suggestions UITableView displays in front of the other UITableView, but problem is that none of the taps to the suggestions UITableView register if they're outside the bounds of the view that contains it.
This is probably a really simple problem dealing more with UIViews in general, but I'm having trouble. Thanks for the help!
You have to adjust your second tableview which is giving you suggestions below testfield which will solve most of your issues
hope it helps you
you can show the second UITableView within another view that is displayed above the current view, like a popover, using
[self.view addSubview:secondView].
Once a selection is made, you can remove this view using
[secondView removeFromSuperview];

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!

Manually scrolling UITableViewController when a UITextField becomes first responder

Harrr pirates!
I'm trying to make a data entry screen using a UITableViewController. It contains a grouped table view with two sections, each with a few (2 and 4) rows with a UITextField inside them.
When any of the UITextFields become first responder they scroll into view automatically. Great, you would say, but I want to scroll the whole section into view, not just the row containing the UITextField that became first responder.
I don't allow the user to scroll the UITableView by hand and I know to what position it should scroll to display correctly. However, I can't get my UITableViewController to stop automatically scrolling the UITextField into view for me.
Searching StackOverflow I can find a lot of questions about how to resize the UITableView when the keyboard appears, but this doesn't stop the automatic scrolling.
Any suggestions? Your help would be much appreciated!
TableView is basically an extension of scrollView therefore if you want to do the scroll yourself you should use the scrollview API.
Set the contectSize property to the size of the screen without the keyboard and the contentOffset to the location on the table you want to scroll to

Problem in UITableView and UIScrollView

My table has more than 10 rows with 50 row height....so i can't select my last row....so i have set UIScrollView and add this table into UIScrollView.
Table display perfectly but which rows are displayed in UIScrollView, these are not selectable.
How can i get this row selecablt in UIScrollView. If anyone body know then pls tell me wha to do?
Thanks,
Haresh.
Putting a UITableView inside a UIScrollView won't work, beause UITableView is a UIScrollView. You're going to have to work out why UITableView won't scroll properly for you on its own.
Check how you initialize it and look at some of Apple's example UITableView code to see what is different.
It may be that your navigation bar, toolbar or some other control is hiding that last row. Check to make sure the tableview partly under another control.