swift - 在 iOS Swift 项目中找不到 'UIView' 的接口(interface)声明

标签 swift uiview ios9 mbprogresshud bridging-header

我有一个 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/

相关文章:

ios - 显示 URL 中的文件文档

swift - Swift 中的隐式类型转换

objective-c - Objective-C - CAGradientLayer 覆盖 UILabel 中的文本?

ios 在显示键盘上强制自动布局更新

ios - CloudKit 无法通过约束与核心数据同步

swift - 为什么以下代码在 iPhone 5 而不是 iPhone 5S 上崩溃?

ios - 简单地用矩形遮盖 UIView

ios - touchesBegin() 创建的 UIView 不会被删除,因为当用户从 iPad 上移开手指时,touchesEnded() 永远不会被调用

ios - ios swift 中的本地化。如何在运行时更改应用程序语言

ios - 找不到 GTMSessionFetcher.h 文件将应用程序升级到最新的 google-api-objectivec-client