//
Mjviewcontroller.m
08-Long Press + swipe
//
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)];
Long press for at least 2 seconds
Longpress.minimumpressduration = 2;
Before triggering the gesture, the 50px range is long by the active
Longpress.allowablemovement = 50;
[Self.redview addgesturerecognizer:longpress];
}
-(void) Longpressview
{
NSLog (@ "Long pressed Red View");
}
@end
iOS gesture recognition-long press + swipe