以非全屏方式呈现 UIView

发布于 2024-10-04 13:50:44 字数 284 浏览 0 评论 0原文

我有一个 200 x 150 px 的视图,我想通过点击按钮来呈现它。如果我使用 addSubview: 那么视图会显示在正确的位置,但我仍然可以点击超级视图上的其他按钮,这是我不想要的行为。

如果我使用presentModalViewController,那么视图会占据整个屏幕,这也是我不想要的......即使我将wantsFullScreenLayout设置为,也会发生这种情况不。

我如何呈现视图,以便用户只能与所呈现视图上的控件进行交互?

谢谢

I have a view 200 x 150 px which i would like to present on the tap of a button. If i use addSubview: then the view shows up in the correct position, but i can still tap other buttons on the superview, which is behaviour i don't want.

If i use presentModalViewController then the view takes up the whole screen, which is what i don't want either... this happens even if i set wantsFullScreenLayout to NO.

How can i present the view so that the user can only interact with controls on the presented view?

Thanks

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

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

发布评论

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

评论(1

左岸枫 2024-10-11 13:50:45

使视图与屏幕大小相同(考虑到状态栏)。该视图应该具有半透明的背景颜色(或透明)。将 200x150 视图置于该视图的底部,以具有 UIActionSheet 的外观,其中背景变暗并且用户无法与屏幕上的其他元素交互。

然后,您可以使用presentModalViewController来呈现视图。

添加

在视图控制器的.m文件中,定义awakeFromNib:

-(void)awakeFromNib
{
    self.view.backgroundColor = [UIColor clearColor];
}

Make the view the size of the screen (taking the status bar into account). That view should have a translucent background color (or clear). Have the 200x150 view be on the bottom of that view to have the appearance of a UIActionSheet, where the background dims and the user cannot interact with other elements on the screen.

Then, you can use presentModalViewController to present the view.

Addition

In the view controller's .m file, define awakeFromNib:

-(void)awakeFromNib
{
    self.view.backgroundColor = [UIColor clearColor];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文