我有一个 swift
项目,我正在通过桥接头文件使用 MBProgressHUD
。我遇到的问题是 UIView
似乎没有被识别为类型,我不知道为什么。
在我的桥接头中我有:
#import "MBProgressHUD.h"
我在尝试构建时遇到的错误都是相同的:
Cannot find interface declaration for 'UIView', superclass of MBProgressHUD.
我检查了 MBProgressHUD 文件,我可以看到它确实导入了以下内容:
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreGraphics/CoreGraphics.h>
#import "MBProgressHUD.h"
#import "CSNotificationView.h"
有没有其他人遇到过类似的问题?如果是,您知道问题出在哪里吗?我该如何解决?
最佳答案
我也遇到了同样的问题,这就是我在 swift 2 中使用 MBProgressHud 所做的
1) 指定use_frameworks!在您的 Podfile 中使用框架。
2) 在桥接头中添加#import,使用尖括号代替双引号,例如 -
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreGraphics/CoreGraphics.h>
#import <MBProgressHUD/MBProgressHUD.h>
3) 在您的 swift 文件中也导入 MBProgressHUD 例如
import UIKit
import MBProgressHUD
现在您可以像这样使用 MBProgressHud -
MBProgressHUD.showHUDAddedTo(self.view, animated: true);
希望对您有所帮助。
关于swift - 在 iOS Swift 项目中找不到 'UIView' 的接口(interface)声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32654346/