iPhone Programming: UIGestureRecognisers

Published: 11 December 2011
on channel: MilmersXcode
2,083
13

A quick tutorial teaching you about UIGestureRecognizers.

Main Code:

(void)viewDidLoad
{
[super viewDidLoad];

UITapGestureRecognizer *tapTwo = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTap)];
[tapTwo setDelegate:self];
[tapTwo setNumberOfTapsRequired:2];
[tapTwo setNumberOfTouchesRequired:1];
[self.view addGestureRecognizer:tapTwo];
[tapTwo release];

UITapGestureRecognizer *tapOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTap)];
[tapOne setDelegate:self];
[tapOne setNumberOfTapsRequired:1];
[tapOne requireGestureRecognizerToFail:tapTwo];
[self.view addGestureRecognizer:tapOne];
[tapOne release];

UISwipeGestureRecognizer *down = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeDown)];
[down setDelegate:self];
[down setDirection:UISwipeGestureRecognizerDirectionDown];
[down requireGestureRecognizerToFail:tapTwo];
[self.view addGestureRecognizer:down];
[down release];

UISwipeGestureRecognizer *up = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeUp)];
[up setDelegate:self];
[up setDirection:UISwipeGestureRecognizerDirectionUp];
[up requireGestureRecognizerToFail:tapTwo];
[self.view addGestureRecognizer:up];
[up release];
}

-(void)singleTap {
NSLog(@"Tapped Once");
}

-(void)doubleTap {
NSLog(@"Tapped Twice");
}

-(void)swipeDown {
NSLog(@"Swiped Down");
}

-(void)swipeUp {
NSLog(@"Swiped Up");
}

Suggested by: Jan-marteen -    / jm11081996  

Twitter:   / failcakeapps  
Apple Developer Center: http://developer.apple.com/devcenter/...
Website: http://failcake.webs.com/
Channel:    / milmersxcode  


On this page of the site you can watch the video online iPhone Programming: UIGestureRecognisers with a duration of hours minute second in good quality, which was uploaded by the user MilmersXcode 11 December 2011, share the link with friends and acquaintances, this video has already been watched 2,083 times on youtube and it was liked by 13 viewers. Enjoy your viewing!