FliperPageViewController.m文件的代码:
#import "fliperPageViewController.h" @implementation fliperPageViewController @synthesize pages; /********************************************************************************* 函数: - (void)viewDidLoad 功能: 启动程序加载首界面,并初始化应用程序 参数: 返回值: **********************************************************************************/ - (void)viewDidLoad { pages=[[NSArray alloc] initWithObjects:@"封面",@"目录",@"1",@"2",@"3",@"4",@"5",@"6", @"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14",@"15",@"16",nil]; currentTag=1; //初始化 [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation: UIStatusBarAnimationSlide]; 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; [self.view addSubview:contentView]; [super viewDidLoad]; }
/********************************************************************************* 函数: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 功能: touch事件,获取触摸的起始位置 参数: 返回值: **********************************************************************************/ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; startPosition = [touch locationInView:self.view]; } /********************************************************************************* 函数:- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 功能: touch事件,获取触摸的结束位置 参数: 返回值: **********************************************************************************/ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; endPosition = [touch locationInView:self.view]; [self handleFlip]; }