开发者

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 some开发者_JAVA百科thing 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?


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; });


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];`


What I found working best is what you mention as possibility 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;
    ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜