How to disable main toolbar when displaying popover using modalInPopover?

I am showing a popover with an contained view controller having a modalInView property set. I need the user to enter the answer here before continuing.

While this disables most user interface controls, it disables the toolbar buttons in the main application. I do not want the user to interact with the application before selecting an element in a popover and closing it.

I missed something smart here - i.e. would disable the toolbar by default? Why does he stay active? Are there any user interface instructions that require it?

Should I just configure the toolbar to prohibit user interaction or is it random?

+6
source share
3 answers

IOS seems to add the panel as an β€œend-to-end view” for the popover when you present it from a UIBarButtonItem.

Just set the nil passthroughViews property to a UIPopoverController after presenting it, for example:

[self.myPopover presentPopoverFromBarButtonItem:some_item permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; dispatch_async(dispatch_get_main_queue(), ^{ self.myPopover.passthroughViews = nil; }); 
+6
source

Instead, use -[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated] , which does not enable the default toolbar interaction. For example, if you are representing from a UIBarButtonItem with a set of customView properties:

 [barButtonItem presentPopoverFromRect:barButtonItem.customView.bounds inView:barButtonItem.customView permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];` 
+2
source

What I found best is what you mention as an opportunity in your question:

 -(void)showMyPopover { .... self.myToolBar.userInteractionEnabled=NO; [self.myPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES] } - (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController { self.myToolBar.userInteractionEnabled=YES; ... } 
+1
source

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


All Articles