gpt4 book ai didi

objective-c - 是否可以从另一个 UIViewController 的 uiview 加载 UIVIewcontroller

转载 作者:行者123 更新时间:2023-12-03 17:07:05 24 4
gpt4 key购买 nike

我有:

  • 一个 UIViewController A
  • UIView B:我将 UIView subview 添加到 UIViewController A
  • UIViewController C

我所做的是:

UIViewController A的viewDidLoad的方法中,我称之为:

UIView *subviewB = [[Subview alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
[subviewB subviewBMethod]; //
[self.view addSubview:subviewB];

SubviewB方法代码是创建一个 View ,这个 View 里面有一个按钮。单击此按钮后,它将更改为 UIViewController C.

我尝试过这个:

[self presentModalViewController:self.UIViewControllerC animated:YES];

我收到此错误消息:

warning: incompatible Objective-C types 'struct UIViewControllerC *', expected 'struct UIViewController *' when passing argument 1 of 'presentModalViewController:animated:' from distinct Objective-C type

当我运行该应用程序时,当我单击按钮时它会立即终止,我打开了控制台错误,没有任何错误消息。我的方法一定是错误的,所以我的问题是:

是否可以从另一个UIViewControllerUIView加载UIVIewcontroller?如果:

  • 是的:怎么做?
  • 否:我该怎么办?

最佳答案

看起来您有这样的声明:

 UIViewControllerC *UIViewControllerC;
^

当你想要的时候:

 UIViewController *UIViewControllerC;

关于objective-c - 是否可以从另一个 UIViewController 的 uiview 加载 UIVIewcontroller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4677120/

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