gpt4 book ai didi

objective-c - UIViewController 呈现另一个 UIViewController

转载 作者:行者123 更新时间:2023-12-04 06:11:50 27 4
gpt4 key购买 nike

我在它上面有一个 UIViewController 1 UIButton(添加为 subview ),在我按下 Button(见下面的图 1)之后,在它上面添加了另一个 UIViewController 2,在一些 Action 后从底部到顶部有动画:

[[[UIApplication sharedApplication] keyWindow] addSubview:self.view];
并且它重叠 UIButton ,我如何添加这个不包含的 subview UIButton (见下图2)
图1:
enter image description here
图片。 2:
enter image description here

最佳答案

您还没有显示动画代码,但我假设您在屏幕外添加 subview ,然后更改它的框架(动画)以将其滑入 View 。

使用 insertSubview:belowSubview: 添加新的 subview 相反,将您的按钮作为第二个参数传递。这样按钮将与新 View 重叠,而不是相反。 addSubview:总是把新观点放在任何其他观点之上。

编辑

从您的评论看来,您正在使用 presentModalViewController: 将第二个 View Controller 添加到屏幕上。所以上面的方法是行不通的。据我所知,如果您以这种方式呈现,则无法将原始 View Controller 中的元素保留在新 View Controller 的 View 之上。

您可能需要创建一个新的 UIWindow并将其设置为 windowLevelUIWindowLevelAlert按住你的按钮。这将使其位于下方的任何 View 之上。将此窗口作为 subview 添加到主窗口。

关于objective-c - UIViewController 呈现另一个 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7685573/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com