Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
OrganizationAdvent CalendarQiitadon (β)
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

カスタムUIGestureRecognizer with Swift

More than 5 years have passed since last update.



  • Bridging-Header.h に以下を追加する
#import <UIKit/UIGestureRecognizerSubclass.h>


cannot assign to 'state' in 'self'


//  UICustomGestureRecognizer.swift
//  Created by Takatomo Okitsu on 2014/12/25.
//  Copyright (c) 2014年 Takatomo Okitsu. All rights reserved.

import UIKit

class UICustomGestureRecognizer :UIGestureRecognizer {

    var _timeOutTimer:NSTimer?

    override func reset() {

    override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {

    override func touchesMoved(touches: NSSet, withEvent event: UIEvent) {

    override func touchesEnded(touches: NSSet, withEvent event: UIEvent) {

    override func touchesCancelled(touches: NSSet, withEvent event: UIEvent) {

    func invalidateTimer() {
        if _timeOutTimer != nil {
            _timeOutTimer = nil;

    func handleTimeOut() {
        self.state = UIGestureRecognizerState.Failed

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away