/*********************************************************************************
函数:-(void)handleFlip
功能: 翻页动画处理
参数:
返回值:
**********************************************************************************/
-(void)handleFlip{
if(startPosition.x > endPosition.x ){
if (currentTag < [pages count]) {
UIView *currentView=[self.view viewWithTag:currentTag];
currentTag++;
UIImageView *contentView = [[[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
//[contentView setImage:[UIImage imageNamed:[pages objectAtIndex:(currentTag-1)]]];
contentView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[pages objectAtIndex:(currentTag-1)] ofType:@"png"]];
[contentView setUserInteractionEnabled:YES];
contentView.tag=currentTag;
[UIView beginAnimations:@"animationID" context:nil];
[UIView setAnimationDuration:0.7f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationRepeatAutoreverses:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[currentView removeFromSuperview];
[self.view addSubview:contentView];
[UIView commitAnimations];
}
}
else {
if (currentTag > 1) { //注意越界
UIView *currentView=[self.view viewWithTag:currentTag];
currentTag--;
UIImageView *contentView = [[[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
contentView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[pages objectAtIndex:(currentTag-1)] ofType:@"png"]];
[contentView setUserInteractionEnabled:YES];
contentView.tag=currentTag;
[UIView beginAnimations:@"animationID" context:nil];
[UIView setAnimationDuration:0.7f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationRepeatAutoreverses:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
[currentView removeFromSuperview];
[self.view addSubview:contentView];
[UIView commitAnimations];
}
}
}
- (void)dealloc{
[pages release];
[super dealloc];
}
@end