码迷,mamicode.com
首页 > 移动开发 > 详细

ios手势识别-长按+轻扫

时间:2014-09-16 12:26:50      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:io   os   ar   2014   sp   cti   log   on   c   

//
//  MJViewController.m
//  08-长按+轻扫
//
//  Created by apple on 14-4-20.
//  Copyright (c) 2014年 itcast. All rights reserved.
//

#import "MJViewController.h"

@interface MJViewController ()
@property (weak, nonatomic) IBOutlet UIView *redView;

@end

@implementation MJViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeView)];
    
    swipe.direction = UISwipeGestureRecognizerDirectionUp;
    
    [self.redView addGestureRecognizer:swipe];
}

- (void)swipeView
{
    NSLog(@"swipeView");
}

- (void)testLongPress
{
    UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] init];
    [longPress addTarget:self action:@selector(longPressView)];
    
    // 至少长按2秒
    longPress.minimumPressDuration = 2;
    
    // 在触发手势之前,50px范围内长按有效
    longPress.allowableMovement = 50;
    
    [self.redView addGestureRecognizer:longPress];
}

- (void)longPressView
{
    NSLog(@"长按了红色的view");
}

@end

ios手势识别-长按+轻扫

标签:io   os   ar   2014   sp   cti   log   on   c   

原文地址:http://www.cnblogs.com/xiaokanfengyu/p/3974620.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!