如何从子视图中隐藏信息按钮?

发布于 2024-09-30 19:36:54 字数 285 浏览 1 评论 0原文

我有一个 mainViewController,在它的 nib 文件中添加了一个信息按钮,其中的操作是在两个子视图(子视图 A 和子视图 B)之间翻转。

从 mainViewController 的 viewDidLoad 下,我插入了子视图 A。在这里我注意到信息按钮位于子视图A的前面,这很好。

问题来了,当按下子视图 A 的 nib 文件中的任何按钮(在其中添加新子视图)时,信息按钮仍保留在前面。

那么,如何将这些后来的子视图添加到所有父视图堆栈的前面,这样信息按钮就不会出现?或者如何隐藏信息按钮?

I have a mainViewController and inside its nib file I added an info button, in which action is to flip between two subviews, subview A and subview B.

From mainViewController, under viewDidLoad, I'm inserting subview A. Here I notice that the info button is in front of the subview A, which is fine.

The problem comes that when pressing any buttons that are located within subview A's nib file, in which they add new subviews, the info button remains on front.

So, how can I add these later subviews on front of all parent view stacks, so the info button does not appear? or how can I hide the info button?

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

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

发布评论

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

评论(1

疯了 2024-10-07 19:36:54

如果我理解正确的话,你的 mainViewController 的视图有两个超级视图:subView A 和 infoButton。您想将子视图添加到显示在 infoButton 视图上的 subviewA 吗?

简单的答案是,您不能使 subviewA 的子视图出现在 infoButton 视图上。如果您将视图层次结构视为一棵树,则渲染器会以深度优先的方式绘制视图。这意味着它会在考虑 infoButton 视图之前绘制 subviewA 以及 subviewA 的所有子视图(依此类推)。如果您希望视图显示在 infoButton 视图上,则需要将其添加为 infoButton after 主视图子视图列表中 infoButton 的同级。

如果您想隐藏 infoButton,只需将 hidden 属性设置为 YES,然后当然,当您希望 infoButton 视图重新出现时,将其设置为 NO。

根据您对 subviewA 执行的操作,您可能会考虑使用模态视图控制器或导航控制器来管理用户与 subviewA 交互时添加的视图。

If I understand correctly, your mainViewController's view has two superviews: subView A and infoButton. You'd like to add subviews to subviewA that appear over the infoButton view?

The simple answer is that you can't make subviews of subviewA appear over the infoButton view. If you think of the view hierarchy as a tree, the renderer draws the views in a depth-first way. This means it draws subviewA, and all of subviewA's subviews (and so on) before it considers the infoButton view. If you want a view to appear over the infoButton view you need to add it as a sibling of infoButton after infoButton in the main view's subview list.

If you'd like to hide the infoButton, you can simply set the hidden property to YES, and then set it to NO when you want the infoButton view to reappear, of course.

Depending on what you're doing with subviewA, you might consider using a modal view controller or a navigation controller to manage the views that you add when the user interacts with subviewA.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文