gpt4 book ai didi

objective-c - 如何访问呈现模态视图的 UIViewController 类/类名?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:31:15 26 4
gpt4 key购买 nike

一个简单的问题

目前我呈现这样的模态视图:

+ (void)showModalController:(id)ContentController InViewController:(UIViewController*)vc withFrame:(CGRect)rect{

UINavigationController *modalViewNavController = [[UINavigationController alloc] initWithRootViewController:ContentController];
modalViewNavController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
modalViewNavController.modalPresentationStyle = UIModalPresentationFormSheet;

[vc presentModalViewController:modalViewNavController animated:YES];

//it's important to do this after presentModalViewController
modalViewNavController.view.superview.frame = rect;

//self.view assumes the base view is doing the launching, if not you might need self.view.superview.center etc.
modalViewNavController.view.superview.center = vc.view.center;

[modalViewNavController release];

我以自定义模式大小传递将要呈现的 UIViewController 内容的值。我还将 UIViewController 的值传递到将显示模式的地方。

就代码而言,如果可能的话,我想知道内容类中的“vc”名称。

编辑

假设我有 2 个类,一个称为 DetailViewController,其中将显示模态。另一个叫做 ModalContentViewController

我想知道 ModalContentViewController 类(当 View 出现或加载时)DetailViewController 的名称。

有什么想法吗?

PD:当前正在使用...

X代码 4.4.1iPad模拟器iOS5.1iOS5.1

最佳答案

寻找 UIViewController 属性 presentingViewController。这是文档中的引述:

If the view controller that received this message is presented by another view controller, this property holds the view controller that is presenting it. If the view controller is not presented, but one of its ancestors is being presented, this property holds the view controller presenting the nearest ancestor. If neither the view controller nor any of its ancestors are being presented, this property holds nil.

因此您可以使用该属性来获取演示 VC 的名称。

关于objective-c - 如何访问呈现模态视图的 UIViewController 类/类名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14167092/

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