SearchBar in SplitViewController - ios

I added SplitViewController in my app.
As per apple, Masterview must be UITableViewController.
So,I added searcher as Tableview HeaderView.
Problem
Searcher is scrolling as tableview scroll.
I want to stick searchBar at top.
Thank you for your time
Help me to solve this

uisplitviewcontroller masterview will not be always uitableviewcontroller. it can have uiviewcontroller also. check this
Does a UISplitViewController's master view always have to be a UITableView?
And additionally you cannot add sticky searchbar in uitableviewcontroller. only possible way is to creating uiviewcontroller and adding searchbar on it.
Here is how this is can be achieved. And it is actually quite simple. (The following example relies on Storyboard, but the mechanism is the same whatever you are using) :
Use UIViewController and NOT a UITableViewController
Add UITableView as the child of the parent UIView
Add a UISearchBarController also as a child view of the UIView, NOT as a child of the UITableView (UITableView and UISearchController are siblings)
Hope it will help you

Related

Make a toolbar that is part of a UIPageViewController

I have been implementing a UIPageViewController and would like to add a toolbar to the bottom of my UIPageViewController that contains 3 buttons. Sadly, I can't figure out how to do this as I can only put the toolbar on one of the UIViewControllerand when I transition to another view controller the toolbar is no longer there. Is it possible to create a toolbar that spans all UIViewController's that are embedded in the UIPageViewController?
Thanks in advance.
edit: I have already implemented my UIPageViewController and have added two UIViewControllers inside the UIPageViewController. Is it still possible? Maybe it is possible to embed my already created UIPageViewController in a UIVIewController?
Create UIViewController and add UIPageViewController in that. Add that toolbar on UIViewController. after adding UIPageviewcontroller bring subview to front that toolbar.
So your view hierarchy will be UIViewController > UIPageviewcontroller > Toolbar.
As your toolbar is added on UIViewController it will be shown above all pageviewcontroller's viewcontroller.

SearchController issue in UITableview

In my code i added UISearchController as UITableView Header.
But if User scroll UItableview then searcher is goes up & hide.
I want to show UISearchBar stick to top.
I don't want to add it in navigation title.
I also try to add in UIViewController but it is disappear when try to search something.
Please help me to solve this.
Thank you,
Don't put the UISearchBar in the header of the UITableView. Put it outside the UITableView. It just means that your view controller will have to subclass UIViewController instead of UITableViewController.

Using UISearchDisplayController in a child controller

I made a tabbed controller where the tabs are on top. Underneath the tabs I have a subview which will contain a tableViewController as a child controller.
The tableViewController has a searchBar and a UISearchDisplayController. The problem is, when the search is activated, the UISearchDisplayController jutts out above the frame of the tableView and covers a bit of the tabs.
I believe this is caused by the SearchBar expanding itself on top to cover up the navigationBar.
Sorry but, why are you using a search display controller?
In this case is easier if you use just a tableView with a searchBar as well as your tab.
Then you can develop the same behaviour of the searchDisplayController.
There are developers that have never used the searchDisplayController. In general i use that just when i have a tableViewController within so just a tableView and a searchBar. But in your case, i would not use that. Take your life easier trust me ;)

UINavigationBar inside UITableViewController

I have some static cells that I want to display, so I have a UITableViewController. There is also a NavigationBar in this scene that contains some buttons at the top. The setup looks like this:
If I had a UIViewController that contained a UITableView in it, the setup would look like:
So, the question is:
Why does the Navigation Bar have to be embedded inside the UITableView when using a UITableViewController? (I have tried putting it elsewhere but IB won't let me)
I know that UITableView is a subclass of UIView, but is it OK that the top level element in the hierarchy is not a View (but a TableView)?
Thanks.
You shouldn't be placing your UINavigationBar in your UITableView. You should be putting your UITableViewController in a UINavigationController, because that will provide a UINavigationBar for you.
So if you select your UITableViewController in the storyboard, you can choose Embed In -> Navigation Controller from the Editor menu. This would be the proper way to do it.
There are two ways to use a UINavigationBar in iOS:
Embedded inside a UINavigationController (recommended)
As a standalone object
For your particular situation, I'd recommend that you put your UITableViewController as the rootViewController of a UINavigationController. That way you automatically get a navigation bar which you can customize according to your needs. In a typical user experience, when you tap some of your table view rows a new view controller will be pushed onto the navigation stack, so you'll probably end up needing a navigation controller anyway.
What if you decide to use a navigation bar as a standalone object? This is perfectly fine, you can use it inside a view hierarchy as an ordinary UIView, but you'll need to create another object that implements the UINavigationBarDelegate protocol and set it as the delegate property of your navigation bar. If you use a UINavigationController the delegate is already set and configured for you. You also need to add/remove navigation items (instances of UINavigationItem) to your navigation bar by using the pushNavigationItem:animated: and popNavigationItemAnimated: methods.
And about your question on the view hierarchy, you can use a UITableView anywhere a UIView is required. The only caveat is that a UITableView is a view hierarchy on its own and that may restrict your layout a little bit.
The way a UITableViewController works, is its root view is a UITableView. So there is no way to put the UINavigationBar anywhere other than in the UITableView.
I tend never to use a UITableViewController as it doesn't really give you much.
If you particularly want to use the UITableViewController, I don't believe that there is any real problem in having the navigation bar within the table view. You just need to make sure that you set the contentInset on the table view such that the navigation bar doesn't block the content. Though it seems a bit backward to do it this way.
My recommendation would be to just use a normal UIViewController with a navigation bar and a table view.
If you actually need functional navigation, you need to put your UITableViewController within a UINavigationController.
Hope this helps :)
Let me know if anything is still unclear.

How to animate a detailViewController view without UINavigationController?

In an iPad app, I have a tableView as a subview of a top level viewController - let's call it topVC. The tableView is controlled by a dedicated viewController, tblVC, which is a property of topVC. I need the tableView to support iPhone-style detailView navigation.
Setting up a UINavigationController property in the topVC.xib in IB, with tblVC wired as the rootViewController, didn't work, so I set it up the UINavigationController programmatically in topVC viewWillAppear: initializing it with tblVC as the rootViewController, and setting its view as a subview of topVC. This functioned as desired but upon rotation to landscape orientation, the navigationController's navigationBar would pop to the top of thetopVC view.
Is it possible to manually achieve detailView navigation with basic iPhone-style slide-in animation without UINavigationController, using UINavigationBar and UINavigationItem? I thought of setting the detailView out of the frame of the tableView and sliding it in manually, but that only made it appear over another subview and slide into the tableView. How to do this?
You could consider using a popover view controller, and host inside it a standard UINavigationController, with your UITableViewController inside that.
Otherwise you're gonna have to roll your own nav-controller. I've found that it's a real PITA to change/affect some of the innate behaviors you're seeing, like repositioning on rotation.

Resources