使用 modalInPopover 显示弹出窗口时如何禁用主工具栏?

发布于 2024-11-19 21:19:20 字数 243 浏览 7 评论 0原文

我正在显示一个弹出窗口,其中包含的视图控制器设置了 modalInView 属性。我需要用户在继续之前在此处输入响应。

虽然这会禁用我的大部分用户界面控件,但它确实会禁用主应用程序上的工具栏按钮。我不希望用户在选择弹出窗口中的项目并关闭它之前与应用程序进行交互。

我在这里错过了一些聪明的东西吗 - 即默认情况下会禁用工具栏?为什么它仍然活跃?是否有一些需要它的用户界面指南?

我应该将工具栏设置为禁止用户交互,还是很混乱?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

晒暮凉 2024-11-26 21:19:20

当您从 UIBarButtonItem 呈现该栏时,iOS 似乎将该栏添加为弹出窗口的“直通视图”。

只需在呈现 UIPopoverController 后将其设置为 nil passthroughViews 属性,如下所示:

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

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; });
铃予 2024-11-26 21:19:20

请改用 -[UIPopoverController PresentPopoverFromRect:inView:permissedArrowDirections:animated],默认情况下不启用工具栏交互。例如,如果从设置了 customView 属性的 UIBarButtonItem 进行呈现:

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

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];`
狠疯拽 2024-11-26 21:19:20

我发现最有效的是你在问题中提到的可能性:

-(void)showMyPopover
{
    ....
    self.myToolBar.userInteractionEnabled=NO;
    [self.myPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]
}

- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
    self.myToolBar.userInteractionEnabled=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;
    ...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文