Disable Scrolling of UISearchbar that is added to UITableView - iphone

I have add a UISearchBAr to the UITableView to implement search functionality.
But after searching is done, the UISearchBar is also scrolling and disappearing along with the UITableView. I just want to know how to make the search bar static with only the UITableView scrolling...

I assume your adding the searchBar to the tableView's headerView, which is why it scrolls along with the rest of the table. Try adding the searchBar to the view (NOT the tableView) and resize the frame of your tableView to be below the searchBar.

Related

UITableView is hidden by a new UITableView when displaying search

I have a UIViewController with a view, containing a UITableView (myTableView) and some buttons. myTableView also has a searchbar. The moment I start searching, myTableView is covered by a new tableview with the search results. Since myTableView is only covering half the screen, and the new tableview covers the entire screen, I have a problem. How can I set the new UITableView to only cover the same part of the screen as myTableView?
Sounds like you may be using UISearchDisplayController, which contains a UITableView to display search results on. If you want to roll your own, just use a UISearchBar and its delegate methods to populate your own table instead of the included results view.

separate uisearchbar & uitableview

I have a problem, there is a way to separate the uisearchbar from uitableview?I want to put the searchbar at the top of the view, a little tableview at the bottom of view and an image between the 2 items?
thank you
kikko

UISearchBar on the top of UITableView which can hide but stay close to UINavigationBar

I would like to have a UISearchBar on the top of my UITableView which hides when you scroll down: The answer is easy, I just need to add it on my table view header like this:
UISearchBar *search = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 45)];
self.tableView.tableHeaderView = search;
[search release];
But the problem is that when you scroll up the UISearchBar fit to the top of the UITableView, and not the top of the UINavigationBar. To be more clear I made a screen in Mail (not good) and Game Center (good).
I want the same as in Game Center. Do you have any idea how they are doing this ?
You will need to hide the search bar on your own when you scroll the tableview. So, don't put it as a UITableView header. You could hide it by setting its height to zero. That way if your tableview is set to autoresize it will expand.
I would experiment with having the UITableView and the UISearchBar as peers within another view. The GameCenter image does not have the search bar as the table view header, rather it has them as separate subviews.
You could also look at UISearchDisplayController but I think it doesn't quite have the behaviour that you want.
Edit: This question is basically your question and has some code in the answers.
A tableview header will move while scrolling downwards. It is tableview's property.
If you want to place a searchBar with navigation bar. Why dont you place the search bar just below the navigation bar. Use search bar and separate tableview.
The right side 's UISearchBar is on the another UIView, it is not a part of UITableView. So, you can add a child view to put the UISearchBar, and another child view is for the UITableView.
This will answer your question :
iPhone: Hide UITableView search bar by default
same concept, different controller.
Good luck.

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

Fit UITableview within Scrollview

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;