Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I disable the main toolbar when displaying a popover using modalInPopover?

I'm displaying a popover with the contained view controller having the modalInView property set. I need the user to enter a response here before continuing.

While this disables most of my user interface controls, it does disable the toolbar buttons on the main app. I don't want the user to interact with the application before selecting an item in the popover and closing it.

Am I missing something clever here - i.e. that would disable the toolbar by default? Why does it remain active? Is there some user interface guidelines that require it?

Should I just set the toolbar to disallow user interaction, or is that messy?

like image 362
dommer Avatar asked Jul 12 '11 23:07

dommer


2 Answers

It seems like iOS adds the bar as a "passthrough view" for the popover, when you present it from UIBarButtonItem.

Just set to nil passthroughViews property of UIPopoverController after presenting it, like this:

[self.myPopover presentPopoverFromBarButtonItem:some_item permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
dispatch_async(dispatch_get_main_queue(), ^{ self.myPopover.passthroughViews = nil; });
like image 195
Igor Vasilev Avatar answered Sep 30 '22 17:09

Igor Vasilev


Use -[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated] instead, which doesn't enable toolbar interaction by default. For example, if presenting from a UIBarButtonItem with a customView property set:

[barButtonItem presentPopoverFromRect:barButtonItem.customView.bounds inView:barButtonItem.customView permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];`
like image 29
Michael Voong Avatar answered Sep 30 '22 18:09

Michael Voong