gpt4 book ai didi

ios - 在另一个 View Controller 上显示一个 View Controller 作为 subview (popoverController)

转载 作者:行者123 更新时间:2023-11-29 00:55:20 24 4
gpt4 key购买 nike

你好,我想在主视图 Controller 上展示一个具有弹出功能的 Controller ,谁能帮我解决这个问题??我已经尝试过下面的代码,但它在所有 View 中都是常见的,我希望它在 View 中心以小尺寸显示。这是下面的代码

Login *popoverController = [[Login alloc] init];
popoverController.popoverPresentationController.sourceView = self.view; //The view containing the anchor rectangle for the popover.
popoverController.popoverPresentationController.sourceRect = CGRectMake(384, 40, 40, 40); //The rectangle in the specified view in which to anchor the popover.
[self presentViewController:popoverController animated:YES completion:nil];

最佳答案

您可以使用容器 View 。将容器 View 添加到您的父 View ,并在您的容器 View 中添加其他 View Controller 。

 self.addChildViewController(vc)
vc.view.frame = CGRectMake(0, 0, self.container.frame.size.width, self.container.frame.size.height);
self.container.addSubview(vc.view)
vc.didMoveToParentViewController(self)

关于ios - 在另一个 View Controller 上显示一个 View Controller 作为 subview (popoverController),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37651663/

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