我有许多想用手势(来回)推动的图像。我知道PageViewController对此非常完美,但我无法弄清楚如何在使用NIB的现有项目中使用它。iOS5轻扫手势切换图像 - 请求帮助
所以。我试图构建一个UIView动画。我可以看到第一个形象,但姿势不工作..
我希望得到任何帮助..
下面是两个程序中的一个代码,再加上手势初始化:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
NSLog(@"%s", __FUNCTION__);
return YES;
}
- (void)handleSwipe:(UISwipeGestureRecognizer *)recognizer {
NSLog(@"%s", __FUNCTION__);
switch (recognizer.direction)
{
case (UISwipeGestureRecognizerDirectionRight):
[self performSelector:@selector(previousPage:)];
//[self previousPage];
break;
case (UISwipeGestureRecognizerDirectionLeft):
[self performSelector:@selector(nextPage:)];
//[self nextPage];
break;
default:
break;
}
}
- (void)nextPage {
[UIView beginAnimations:@"fadeOut" context:nil];
[UIView setAnimationDelay:0.0f];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
pageNumber ++;
if(pageNumber > maxInfoPages)
{
pageNumber = 1;
}
NSString *imageName = [NSString stringWithFormat:@"infoPage%i.png", pageNumber];
imageView.image = [UIImage imageNamed:imageName];
NSLog(@"imageName is: %@", imageName);
NSLog(@"imageView is: %@", imageView);
imageView.clipsToBounds=YES;
self.view = imageView;
[UIView commitAnimations];
}
非常感谢
您是否已将手势识别器附加到视图中有问题吗? – timthetoolman
谢谢。是的,我更新了上面的代码。 –