IOS8 UIToolbar disappears when displaying a detailed view controller

I am working with an application using the UISplitViewController as the window root. I would like both the main and the part view manager to be a UITableViewController inside the UINavigationController , with the UIToolbar visible. In horizontal dimension width, this works great, as shown:

iPad 2

The problem lies in the horizontally compact size class, where the UISplitViewController pushes the detail view controller onto a stack like the UINavigationController , the toolbar disappears as the part is displayed and appears again after it has popped up (see below). I would like the toolbar to remain in place, as with a normal navigation controller.

enter image description here

An example of a loaded project is here .

+6
source share
2 answers

For this initial implementation, I think that Apple decided to hide the master toolbar, since the (main) navigation controller cannot use one toolbar to display on the screen and push apart (different elements) on the screen. If you look at the Apple Mail app, their main toolbar will disappear during the push animation, as you can see.

Interestingly, the Calendar application uses a very nice crossFade toolbar between the transitions of the day controller and event. If you look at this animation, you will see that this is the only toolbar for both views, and not the second toolbar, the animation is higher than the first.

Although crossFade is privately maintained by the UINavigationController , Apple does not enable it for this particular controller animation. _shouldCrossFadeBottomBars returns NO, and there is no setting for the delegateShouldCrossFadeBottomBars dispatcher flag.

I would send an error report along with an extension request to support lower bar animation for the unified storyboard UISplitViewController . I believe that Apple will improve the functionality of the iPhone split-card controller.

In the meantime, you can handle this by hiding the toolbar of the main navigation controller and adding the toolbar to the storyboard of the main controller. This will allow the built-in toolbar of the main view controller to be on the screen, while the elements of the detailed view control panel move.

This will change your UITableViewController wizard to a UIViewController . Add UIToolbar and restrictions. For a table, you can go into a UITableView or use the container view and connect it to your UITableViewController .

Customize the detail view DetailViewController in the DetailViewController .

 - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] init ...]; self.toolbarItems = @[barButtonItem]; [self configureView]; } 

The navigation controller will configure the toolbar items (after the view has loaded, but) before the view appears, and the toolbar is clicked on the screen along with the detailed view.

If you're interested, here's what I understand to work with the detail view toolbar for a horizontally compact class. This is an additional navigation controller, not a detailed view controller, which gets on the stack of the main controller. The primary navigation controller takes its decoration from the secondary navigation controller along with the navigationItems (and toolbarItems ) belonging to its visible (detailed) view controller.

Unfortunately, the trickster behind the scenes to collapse the secondary (navigation) controller with separate viewing affects your toolbar because the main navigation controller took responsibility for handling the secondary navigation controller.

All we did was move the secondary toolbar from the secondary navigation controller to the detailed view controller, so the main navigation controller can process the animation of the toolbar of the detailed view controller when you click on the additional navigation controller.

Perhaps in a future update, the split view controller will be able to animate the storyboard toolbar, but so far the only way I know how to do this is through code.

+6
source

If you need to use the Master Parts application without changing the standard view controllers, and you are fine with the toolbar disappearing when you click on the detailed view controller ... you can add the following line of code to the main view controller in viewWillAppear, so, when it pops up, the toolbar is present during the session, not waiting for the appearance until the segue operation is performed.

 self.navigationController?.setToolbarHidden(false, animated: true) 

Of course, you can remove the standard table view manager and use the standard view manager with a table view in it and add a toolbar, then you do not have this problem. It breaks the line of code because it is no longer in the table view controller, and the standard navigation controller does not support cleararsSelectionOnViewWillAppear.

 tableView.clearsSelectionOnViewWillAppear = self.splitViewController!.collapsed 

You can fix this by adding this code to your viewWillAppear ...

  if let indexPath = tableView.indexPathForSelectedRow { tableView.deselectRowAtIndexPath(indexPath, animated: true) } 
+3
source

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


All Articles