WEB开发网
开发学院手机开发iPhone 开发 iPhone SDK 3.2 手势识别 阅读

iPhone SDK 3.2 手势识别

 2010-02-08 01:34:00 来源:WEB开发网   
核心提示:- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {// Disallow recognition of tap gestures in the segmented

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {

// Disallow recognition of tap gestures in the segmented control.

if ((touch.view == segmentedControl) && (gestureRecognizer == tapRecognizer)) {

return NO;

}

return YES;

}

- (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {

CGPoint location = [recognizer locationInView:self.view];

[self showImageWithText:@"swipe" atPoint:location];

if (recognizer.direction == UISwipeGestureRecognizerDirectionLeft) {

location.x -= 220.0;

}

else {

location.x += 220.0;

}

[UIView beginAnimations:nil context:NULL];

[UIView setAnimationDuration:0.55];

imageView.alpha = 0.0;

imageView.center = location;

[UIView commitAnimations];

}

- (void)handleRotationFrom:(UIRotationGestureRecognizer *)recognizer {

CGPoint location = [recognizer locationInView:self.view];

CGAffineTransform transform = CGAffineTransformMakeRotation([recognizer rotation]);

imageView.transform = transform;

[self showImageWithText:@"rotation" atPoint:location];

[UIView beginAnimations:nil context:NULL];

[UIView setAnimationDuration:0.65];

imageView.alpha = 0.0;

imageView.transform = CGAffineTransformIdentity;

[UIView commitAnimations];

}

- (void)handleTapFrom:(UITapGestureRecognizer *)recognizer {

CGPoint location = [recognizer locationInView:self.view];

[self showImageWithText:@"tap" atPoint:location];

[UIView beginAnimations:nil context:NULL];

[UIView setAnimationDuration:0.5];

imageView.alpha = 0.0;

[UIView commitAnimations];

}

Tags:iPhone SDK 手势

编辑录入:coldstar [复制链接] [打 印]
赞助商链接