ToolBar between UINavigationBar and UITableView?

I have a UITableViewController built into the UINavigationController. This tableView is an instance of NSFetchedResultsController. I need to add a toolbar between the top NavigationController and TableViewController, but I cannot figure out how to do this (I don't even know if this is possible). I want to do something like Apple with their WWDC application (except that they don't have a TableViewController built into the NavigationController). I need to have some controls in the panel to control the NSFetchedResultsController.

Some people have suggested people with similar problems use UITableView instead of TVC, but I need to have TVC as an instance of NSFetchedResultsController.

Any ideas on how to do this? Should I do this programmatically? If so, how?

By the way, I aimed at iOS6 + with pivot files and ARC.

Apple's WWDC App

0
source share
6 answers

The approach I prefer is to use the UIViewController externally, containing your toolbar and view of the container that contains the table. Then create the table in a separate UITableViewController and navigate it as a container using the built-in segment. In general, I think this makes the code more modular and easier to follow because a high-level structure is laid out in the storyboard.

The steps for using the built-in segue are as follows:

  • Control the drag and drop from the container view to the view controller that you want to embed and select the "Paste" option.
  • Give inline identifier in attribute inspector.
  • Configure the table view controller in the prepareForSegue parent method by checking your segue identifier.

Here is an example of this in my VCollectionViewGridLayout library. Check out the Sort and Filter sample project.

+6
source

Technical Note TN2154: UIScrollView and Autolayout provides another solution:

Note that you can make the subview scroll view appear as a float (not scroll) on other scrollable content, creating restrictions between the view and the view outside the scroll subtree, for example, scroll view.

That is, even if the scroll view (for example, a table view) changes the frame of the subframes, the automatic layout mechanism will be reset on the next layout.

+2
source

you need to use a UIViewController, then add a toolbar and a tableView instance of the NSFetchedResultsController class inside it in the storyboard

+1
source

You can make the topBar of any UIView, and then pass it as a tableHeaderView. It can help you.

0
source

Use the UIViewController instead of the UITableViewController , where you can easily place other controls besides just the UITableView .

Hope this helps.

0
source

You can use the UITableViewController (keep subtleties like UIRefreshControl support and keyboard avoidance). You just need to embed your toolbar in a simple view and put it in your tableHeaderView. Then follow this scroll view delegate method to lock.

 #pragma mark - UIScrollViewDelegate - (void)scrollViewDidScroll:(UIScrollView *)scrollView { CGRect rect = self.toolbarContainerView.frame; rect.origin.y = MIN(0,scrollView.contentOffset.y + scrollView.contentInset.top); self.toolbarContainerView.frame = rect; } 

Please note that if you also use the section header, you will have to send these views for your TableHeaderView, otherwise they will float through tableHeaderView.

0
source

Source: https://habr.com/ru/post/1497262/


All Articles