The way to put a Header to UITableView in a storyboard is explained in another thread, that you drag and drop your component (in my case a view) on top of the first proto cell. That sticks than as tableview header (not section)
My Problem is, if you drag and drop e.g. a SearchBar and run the app, the seacrh bar is behind the NavigationBar, you can pull the tableview down and you see the searchbar.
If you do the same with a view, you can never put the view away with scrolling up the tableview, it is always visible.
Does anyone know how to hide it like as the search bar ?
Might be this answer is too late but for others maybe useful
after i googled it, i ended with this question , and yeaaa this save my day
Click here
Related
I got a funny question: "Can someone explain this behaviour?"
Click here to view .gif (I'm not allowed to post pictures yet)
Explanation: When I click on the search bar a new ViewController is being presented (the one you see in the gif). There the keyboard is immediately popping up. When I now dismiss the keyboard by scrolling down it seems like the cells that were behind the keyboard re-render or were not loaded yet... I have no clue where to search for this, so I spared the hassle of posting unnecessary code.
Thanks! :-)
Nothing is wrong with the gif. UITableView cells are created and reused when necessary. That is when they become visible or invisible. Since you changed the view controller with the keyboard popped up, only visible cells are created. The ones behind the keyboard are not initialized yet.
I have two UITableViews but they appear in the same UIViewController. That said, one acts as a reveal (slide out) side menu, and its code is housed inside SideMenuViewController.h/.m, and the other TableView is constantly visible in the ViewController.
I'm trying to make it so that I can long press on a cell in the side menu, and drag the selected cell into the TableView on ViewController.
Is this do-able? I've been searching high and low for tutorials, but this doesn't seem like a common ask. Open to all assistance.
I would like to use a UISearchBar and put it towards the bottom of a screen in order to search for available names through an API call. I want to have this SearchBar as part of a sign up form. However, when I put the SearchBar on the screen where I would like through the Storyboard, it does not show up when I run the app on the simulator. When I looked up this issue, everyone is putting the searchbar in a tableview. Am I not using the correct UI element for my cause?
The reason your search bar is not on the screen is probably because you didn't set constraint correctly or it was hidden or covered by some other view.
And for your second half of the question, I myself never put a search bar on a UITableView itself. Some apps put a search bar on the first cell of a table view but you have to scroll to make it show up. I myself always prefer to put it on the navigation controller on the top of the screen so that it will always be there and ready for user to search anything.
All previous questions are relating to anchoring table view section headers, but I would like to know if its possible to anchor the main header below the navigation bar?
I'm using a UISearchController and adding its search bar to the table header, which appears thus:
But because the header is not anchored it and the search bar will disappear if the user scrolls:
Therefore I want to know if its possible to anchor the table header below that navigation bar? Can't find any previous questions relating to this, only relating to anchoring section headers. Fiddling around with the various storyboard settings such as bouncing and scrolling wasn't fruitfull.
P.S.
Any proposed solutions involving manually adding a search bar to a section header and anchoring that instead is I just know going to lead to too much hassle and problems when the search bar becomes active. Using UISearchController and adding its search bar to the table view header nicely animates the navigation bar out of the way and slides the search bar up and down as it gains/loses first responder status:
All this is handled automatically by the UISearchController automatically simply by adding one line of code (to add the search bar to the header).
Therefore I don't want to go down the road of replacing all the UISearchController provided functionality with custom table section headers and so on.
Have you considered just putting it outside the UITableView?
I believe that would be the easiest and most straightforward solution.
Edit:
Take a look at this solution: Fixed UISearchBar using UISearchController - Not using header view of UITableView
Edit 2:
I figured it out.
Here you go!: https://github.com/gorillatech/TableSearchwithUISearchController
My first answer was actually the one that works the best. You just have to add a UIView above the UITableView.
Then you add the UISearchController's searchBar to said view:
[_searchView addSubview:self.searchController.searchBar];
I have a UITableView that when first displayed it displays correctly with the first row appearing on top. When I select a cell another UITableView is presented. If I used the back button on the UINavigation Bar the original UITableView is shifted down with a blank space between the UINavigation Bar and the UITableView.
I am not using story boards. I am using XIB files. I am also using a sliding menu that I got the code for from Ray Wenderlich's web site.
When I slide back the main screen over the first UITableView it goes back to its proper position. But then when I select an entry again the issue described above appears.
I found another post that seems to provide an answer to the issue. This post says to make some adjustments like to the translucent settings or the auto-layout settings but doesn't give specifics.
Here is that post: Container View getting pushed down as if it had a UINavigationBar?
Thanks,
Glenn
Add
self.automaticallyAdjustsScrollViewInsets = NO;
in viewDidLoad, of the UIViewController where you have the shifting table view