使用Swift和Xcode 6对UIGestureRecognizer进行子类化 - 如何导入UIGestureRecognizerSubclass.h? [英] Subclassing UIGestureRecognizer with Swift and Xcode 6 - how do I import UIGestureRecognizerSubclass.h?

查看:119
本文介绍了使用Swift和Xcode 6对UIGestureRecognizer进行子类化 - 如何导入UIGestureRecognizerSubclass.h?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除非导入 UIGestureRecognizerSubclass.h self.state =https://developer.apple.com/library/ios/documentation/uikit/reference/UIGestureRecognizer_Class/Reference/Reference.html>,如此处所示



在Swift环境中,我很困惑如何导入它。我尝试了导入UIGestureRecognizerSubclass.h ,没有 .h ,但我仍然无法写入 self.state



我将如何做到这一点?

解决方案

您需要拥有或创建一个-Bridging-Header.h文件来导入objc标头,例如您想要的标头。导入行如下所示:

  #import< UIKit / UIGestureRecognizerSubclass.h> 

如果您的应用中还没有桥头文件,最简单的方法是获取一个是为你的项目添加一个objc类,xcode会询问你是否需要一个,然后创建文件并将其绑定到你的设置中。然后,您可以删除objc类。



该头文件中的所有内容都会自动提供给您的Swift代码,无需在swift文件中添加任何导入行。 / p>

You can't write to self.state in the subclass unless you import UIGestureRecognizerSubclass.h as indicated here.

In a Swift environment, I'm confused how I'd go about importing this. I tried import UIGestureRecognizerSubclass.h, and without the .h, but I still can't write to self.state.

How would I accomplish this?

解决方案

You need to have or create a -Bridging-Header.h file to import objc headers such as the one you want. The import line looks like this:

#import <UIKit/UIGestureRecognizerSubclass.h>

If you don't already have a bridge header file in your app, the easiest way to get one is to add an objc class to your project, and xcode will ask if you want one, then creates the file and ties it into the settings for you. You can then delete the objc class.

Everything in that header file is automatically made available to your Swift code, no need to add any import lines in your swift files.

这篇关于使用Swift和Xcode 6对UIGestureRecognizer进行子类化 - 如何导入UIGestureRecognizerSubclass.h?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆