Created
April 21, 2010 03:18
-
-
Save NYiPhoneDeveloper/373378 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "UsingViewsViewController.h" | |
@implementation UsingViewsViewController | |
@synthesize pageControl; | |
@synthesize image_1, image_2; | |
/* | |
// The designated initializer. Override to perform setup that is required before the view is loaded. | |
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { | |
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { | |
// Custom initialization | |
} | |
return self; | |
} | |
*/ | |
/* | |
// Implement loadView to create a view hierarchy programmatically, without using a nib. | |
- (void)loadView { | |
} | |
*/ | |
- (void)viewDidLoad | |
{ | |
[image_1 setImage: [UIImage imageNamed: @"Chess_32.png"]]; | |
tempImageView = image_2; | |
[image_1 setHidden: NO]; | |
[image_2 setHidden: YES]; | |
[pageControl addTarget: self action: @selector(pageTurning: ) forControlEvents: UIControlEventValueChanged]; | |
[super viewDidLoad]; | |
} | |
-(void) pageTurning: (UIPageControl *) pageController | |
{ | |
NSInteger nextPage = [pageController currentPage]; | |
switch (nextPage) | |
{ | |
case 0: | |
[tempImageView setImage: [UIImage imageNamed: @"Chess_32.png"]]; | |
break; | |
case 1: | |
[tempImageView setImage: [UIImage imageNamed: @"Coffee_32.png"]]; | |
break; | |
case 2: | |
[tempImageView setImage: [UIImage imageNamed: @"Java_32.png"]]; | |
break; | |
default: | |
break; | |
} | |
if (tempImageView.tag == 0) | |
{ | |
tempImageView = image_2; | |
bgImageView = image_1; | |
} | |
else | |
{ | |
tempImageView = image_1; | |
bgImageView = image_2; | |
} | |
[UIView beginAnimations: @"Flip View" context: nil]; | |
[UIView setAnimationDuration: 0.5]; | |
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut]; | |
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView: tempImageView cache: YES]; | |
[tempImageView setHidden: YES]; | |
[UIView commitAnimations]; | |
[UIView beginAnimations: @"Flip View" context: nil]; | |
[UIView setAnimationDuration: 0.5]; | |
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView: bgImageView cache: YES]; | |
[bgImageView setHidden: NO]; | |
[UIView commitAnimations]; | |
} | |
/* | |
// Override to allow orientations other than the default portrait orientation. | |
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { | |
// Return YES for supported orientations | |
return (interfaceOrientation == UIInterfaceOrientationPortrait); | |
} | |
*/ | |
- (void)didReceiveMemoryWarning { | |
// Releases the view if it doesn't have a superview. | |
[super didReceiveMemoryWarning]; | |
// Release any cached data, images, etc that aren't in use. | |
} | |
- (void)viewDidUnload { | |
// Release any retained subviews of the main view. | |
// e.g. self.myOutlet = nil; | |
} | |
- (void)dealloc { | |
[image_1 release]; | |
[image_2 release]; | |
[pageControl release]; | |
[super dealloc]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment