首页 > 解决方案 > 找不到“MapViewControllerDelegate”的协议声明;你的意思是“UIPageViewControllerDelegate”吗?

问题描述

我有一个用目标 C 编写的应用程序,我在 2 个月前上传了一个新版本,一切正常,现在我想添加一些东西,但我收到这个错误:找不到协议声明MapViewControllerDelegate;你的意思是UIPageViewControllerDelegate

#import <UIKit/UIKit.h>

@protocol MapViewControllerDelegate <NSObject>

-(void)closeViewController;

@end

@interface RoomServiceViewController : UIViewController
@property (weak,nonatomic) id <MapViewControllerDelegate> delegate;

@end

找不到协议声明MapViewControllerDelegate;你的意思是UIPageViewControllerDelegate

替换MapViewControllerDelegateUIPageViewControllerDelegate

引用MapViewControllerDelegate不明确

标签: iosobjective-cxcodeuipageviewcontroller

解决方案


由于您标记了 UIPageViewController 并且 XCode 是您的类型与 UIPageViewControllerDelegate 混淆:您在某处是否有一个 UIPageViewController 也指您的协议?

如果是:Objective-C 类型在您的项目中不会自动知道。你需要包含他们的头文件。否则你会得到有趣的最佳猜测。

另外的选择。将协议移动到单独的头文件中,看看是否可以解决问题。

此外,如果您使用 include 而不是 import 您最终会出现奇怪的编译器错误。


推荐阅读