gpt4 book ai didi

ios - 将 View Controller 的 View 扩展到全屏

转载 作者:行者123 更新时间:2023-11-29 12:59:45 28 4
gpt4 key购买 nike

我的应用程序中有一个相当复杂的 View Controller 层次结构。我目前有一个 View ,我想通过点击按钮使其全屏显示。问题是,因为这个 View 位于只占屏幕一部分的 View Controller 的 View 内,所以我无法简单地将框架设置为应用程序窗口的大小。我也无法以模态方式呈现 View ,因为这会干扰我的 UI 的其余部分。

帮助解释我的意思:

UIViewController // root view controller
--> UIViewController
--> UIViewController
--> UIViewController
--> UIViewController
--> Controller's View <----- // this one
--> UIViewController

我需要制作上面显示的 View ,因为它已经显示在 View Controller 中以扩展到全屏。

有什么办法可以解决这个问题吗?

最佳答案

我正在做一些类似的事情,希望对您有所帮助。我有支持全屏视频的视频播放器。

请查看此代码,您需要进行更改,因为这只是我的代码的一部分,其中一些更改只是为了展示我是如何做到的。

UIView *rootView =  [[[[[UIApplication sharedApplication] delegate] window] rootViewController] view];
CGRect rect = [myView convertRect: myView.frame toView:rootView];
UIView *interactionView = [[UIView alloc] initWithFrame:rect];
interactionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
[interactionView.layer insertSublayer:myView.layer below:otherView.layer ];// i am using otherView u can use if any or use addSublayer otherwise
myView.layer.frame = rootView.bounds;
interactionView.frame = rootView.bounds;

关于ios - 将 View Controller 的 View 扩展到全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20093389/

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