【问题标题】:Warning when presenting a UIViewController呈现 UIViewController 时的警告
【发布时间】:2011-01-18 21:28:34
【问题描述】:

我正在创建另一个实例我的主视图控制器并展示它。

MainViewController *sm = [[MainViewController alloc]initWithNibName:@"MainViewController" bundle:nil];
[self presentModalViewController:sm animated:NO];
[sm release];

这会产生以下错误

警告:receiver 'MainViewController' 是一个转发类,对应的@interface 可能不存在

警告:当从不同的 Objective-C 类型传递“presentModalViewController:animated:”的参数 1 时,Objective-C 类型“struct MainViewController *”不兼容,预期为“struct UIViewController *”

我做错了什么?如何呈现当前存在的 MainViewController 版本?

【问题讨论】:

    标签: iphone uiviewcontroller


    【解决方案1】:

    你的头文件中有一个前向声明

    @class MainViewController;
    

    但是你没有在你的实现文件中导入头文件。

    添加

    #import "MainViewController.h"
    

    到 .m 文件的顶部。

    【讨论】:

      【解决方案2】:

      导入“MainViewController.h”

      在您的 .m 文件中。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-09-05
        • 1970-01-01
        • 2012-07-28
        • 2016-11-29
        • 1970-01-01
        • 2016-06-21
        • 1970-01-01
        相关资源
        最近更新 更多