Subclassing UIGestureRecognizer with Swift and Xcode 6 - how do I import UIGestureRecognizerSubclass.h?

前端 未结 2 744
轻奢々
轻奢々 2021-01-07 18:13

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

In a Swift environment, I

2条回答
  •  有刺的猬
    2021-01-07 18:37

    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 
    

    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.

提交回复
热议问题