How to intercept iPhone rotation - iphone

in my app I got a Home with several buttons. Each button opens a separate view. In each view, if I put the device in landscape a help view is shown. Everything works fine except that in whatever view I am, if I put the iPhone like to lay on a table (I don't know how to eplain better...) the app exites from that view and comes back to the first view, the Home.
Here's my code:
- (void)viewDidLoad
{
[super viewDidLoad];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(orientationChanged:)name:#"UIDeviceOrientationDidChangeNotification"
object:nil];
[self performSelector:#selector (ritardo) withObject:nil afterDelay:5.0f];
}
-(void)orientationChanged:(NSNotification *)object{
UIDeviceOrientation deviceOrientation = [[object object] orientation];
if (deviceOrientation == UIInterfaceOrientationPortrait)
{
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
self.view = self.portraitView;
}
else if (deviceOrientation == UIInterfaceOrientationLandscapeLeft || deviceOrientation
== UIInterfaceOrientationLandscapeRight)
{
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
self.view = self.landscapeView;
}
[UIView commitAnimations];
[self dismissModalViewControllerAnimated:NO];
}
-(void) ritardo {
ruota.image = [UIImage imageNamed:#"RuotaPerAiuto.png"];
}
- (void)viewDidUnload
{
[self setPortraitView:nil];
[self setLandscapeView:nil];
[self setRuota:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
#end
Hi hope you can help me
EDIT:
I modified the -(void)orientationChanged:(NSNotification *)object{ in this way:
-(void)orientationChanged:(NSNotification *)object{
UIDeviceOrientation deviceOrientation = [[object object] orientation];
if (deviceOrientation == UIDeviceOrientationFaceUp)// || deviceOrientation ==
UIDeviceOrientationFaceDown)
{
return;
}
if (deviceOrientation == UIInterfaceOrientationPortrait || deviceOrientation ==
UIInterfaceOrientationPortraitUpsideDown)
{
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
self.view = self.portraitView;
}
else
if (deviceOrientation == UIInterfaceOrientationLandscapeLeft || deviceOrientation ==
UIInterfaceOrientationLandscapeRight)
{
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
self.view = self.landscapeView;
}
[UIView commitAnimations];
[self dismissModalViewControllerAnimated:NO];
}
Now, if I'm in portrait and get the iPhone to faceUp position works good. But when I change position from faceUp to portrait it goes back to the home...

The problem is that UIDeviceOrientationDidChangeNotification will be fired independently from shouldAutorotateToInterfaceOrientation. And you don't handle the cases UIInterfaceOrientationPortraitUpsideDown, UIDeviceOrientationFaceUp and UIDeviceOrientationFaceDown in the method orientationChanged:. So when the device is rotated to one of these orientations, your code is equivalent to:
-(void)orientationChanged:(NSNotification *)object
{
[UIView commitAnimations];
[self dismissModalViewControllerAnimated:NO];
}
So you should remove the lines:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(orientationChanged:)name:#"UIDeviceOrientationDidChangeNotification" object:nil];
and put you code in the method willRotateToInterfaceOrientation:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
self.view = self.portraitView;
} else {
self.view = self.landscapeView;
}
[UIView commitAnimations];
[self dismissModalViewControllerAnimated:NO];
}
Edit
If you want to keep orientationChanged, then modify it as follows:
-(void)orientationChanged:(NSNotification *)object{
UIDeviceOrientation deviceOrientation = [[object object] orientation];
if (deviceOrientation == UIInterfaceOrientationPortrait) {
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
self.view = self.portraitView;
[UIView commitAnimations];
[self dismissModalViewControllerAnimated:NO];
} else if (deviceOrientation == UIInterfaceOrientationLandscapeLeft || deviceOrientation == UIInterfaceOrientationLandscapeRight) {
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
self.view = self.landscapeView;
[UIView commitAnimations];
[self dismissModalViewControllerAnimated:NO];
}
}

Related

iAd is not loading in iPhone but loading in iPad after approval from apple

I have developed an application which recently approved from apple. But problem is iAd is not showing in iphone where as in ipad iAd is showing perfectly. At the time of development iAd is loaded and worked with test advertisement in both iPhone and iPad. But after approval from apple i have downloaded application from store noticed that iAd is not loading in iphone but it was loading in ipad. I have check other application in iphone in other application iAd is working fine but in my application iAd is not loading. So what should i do now to load the iAd in iphone.
My code that i used in the application was
-(void)showiAdInView
{
if (!appDelegate.isUpgraded) {
bannerView = [[ADBannerView alloc] init];
bannerView.delegate = self;
bannerView.backgroundColor = [UIColor colorWithWhite:1.0f alpha:0.005f];
bannerView.hidden = TRUE;
bannerIsVisible = FALSE;
[self.view addSubview:bannerView];
}
}
-(void)bannerViewDidLoadAd:(ADBannerView *)banner
{
bannerIsVisible = YES;
bannerView.hidden = FALSE;
NSLog(#"ADBanner is Showing");
[self bannerViewShow];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
bannerIsVisible = FALSE;
bannerView.hidden = TRUE;
NSLog(#"ADBanner is Hidding");
NSLog(#"%#",[error description]);
[self bannerViewHide];
}
-(BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication: (BOOL)willLeave
{
if ([self.captureSession isRunning]) {
[self.captureSession stopRunning];
iAdLoaded = TRUE;
}
return YES;
}
-(void)bannerViewActionDidFinish:(ADBannerView *)banner
{
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
[self willRotateToInterfaceOrientation:interfaceOrientation duration:0.2f];
if (![self.captureSession isRunning] && iAdLoaded) {
[self.captureSession startRunning];
iAdLoaded = FALSE;
}
}
-(void)bannerViewShow
{
[bannerView setBackgroundColor:[UIColor colorWithWhite:1.0f alpha:0.005f]];
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[MsgtextView setFrame:MsgTextVwAdBannerFrame];
[UIView commitAnimations];
adBannerFrame = CGRectMake(0, 190, 320, 50);
clearButton.frame = CGRectMake(ClearButtonFramePotrait.origin.x, ClearButtonFramePotrait.origin.y, ClearButtonFramePotrait.size.width, ClearButtonFramePotrait.size.height);
[self.view bringSubviewToFront:bannerView];
[bannerView setFrame:adBannerFrame];
[bannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait];
}
else if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[MsgtextView setFrame:CGRectMake(MsgTextVwAdBannerFrame.origin.x, MsgTextVwAdBannerFrame.origin.y, MsgTextVwAdBannerFrame.size.width, MsgTextVwAdBannerFrame.size.height+8)];
[UIView commitAnimations];
adBannerFrame = CGRectMake(0, 105, 470, 32);
clearButton.frame = CGRectMake(ClearButtonFrameLandscape.origin.x, ClearButtonFrameLandscape.origin.y, ClearButtonFrameLandscape.size.width, ClearButtonFrameLandscape.size.height);
[bannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierLandscape];
[self.view bringSubviewToFront:bannerView];
[bannerView setFrame:adBannerFrame];
}
}
else if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[MsgtextView setFrame:MsgTextVwAdBannerFrame];
[UIView commitAnimations];
adBannerFrame = CGRectMake(0, 640, 768, 50);
[bannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierPortrait];
clearButton.frame = CGRectMake(ClearButtonFrame_iPadPotrait.origin.x, ClearButtonFrame_iPadPotrait.origin.y, ClearButtonFrame_iPadPotrait.size.width, ClearButtonFrame_iPadPotrait.size.height);
[self.view bringSubviewToFront:bannerView];
[bannerView setFrame:adBannerFrame];
}
else if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[MsgtextView setFrame:CGRectMake(MsgTextVwAdBannerFrame.origin.x, MsgTextVwAdBannerFrame.origin.y, MsgTextVwAdBannerFrame.size.width, MsgTextVwAdBannerFrame.size.height+8)];
[UIView commitAnimations];
adBannerFrame = CGRectMake(0, 325, 1024, 32);
[bannerView setCurrentContentSizeIdentifier:ADBannerContentSizeIdentifierLandscape];
clearButton.frame = CGRectMake(ClearButtonFrame_iPadPotrait.origin.x, ClearButtonFrame_iPadPotrait.origin.y, ClearButtonFrame_iPadPotrait.size.width, ClearButtonFrame_iPadPotrait.size.height);
[self.view bringSubviewToFront:bannerView];
[bannerView setFrame:adBannerFrame];
}
}
}
-(void)bannerViewHide
{
[bannerView setBackgroundColor:[UIColor clearColor]];
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[MsgtextView setFrame:MsgTextVwFrame];
clearButton.frame = ClearButtonFramePotrait;
[bannerView setHidden:YES];
[UIView commitAnimations];
}
else if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[MsgtextView setFrame:MsgTextVwFrame];
clearButton.frame = ClearButtonFrameLandscape;
[bannerView setHidden:YES];
[UIView commitAnimations];
}
}
else if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[MsgtextView setFrame:MsgTextVwFrame];
clearButton.frame = ClearButtonFrame_iPadPotrait;
[bannerView setHidden:YES];
[UIView commitAnimations];
}
else if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[MsgtextView setFrame:MsgTextVwFrame];
clearButton.frame = ClearButtonFrame_iPadPotrait;
[bannerView setHidden:YES];
[UIView commitAnimations];
}
}
}
iAd, overall, has a pretty low fill rate. Ad networks (iAd included) send you more ads the better your click-through-rate is; ie., the ratio of users who click ads in your app : ads you display in your app. If you have confirmed test ads were working and you've just released the app, it's entirely possibly it's just taking a little while for Apple to send you ad fils on the iPhone build. Give it a couple days and see how it goes.
Alternately, I notice your 'isUpgraded' code, there--is it possible that, on the iPhone you're testing on, you purchased the upgrade and forgot, and are now no longer returning ads?

in iOS5 my methods for switching pictures in gallery are bad

I have some classes for watching pictures in gallery. in those classes after enabling ARC i get message that implicit conversion is forbidden by ARC and I cant run the application.
Those methods are:
- (void) curlToPrevious
{
if (currentImageIndex == 0) return;
if ([self.image2 superview] == NO) {
self.image2.image = (UIImage*) [imageViews objectAtIndex:(currentImageIndex-1)];
} else {
self.image1.image = (UIImage*) [imageViews objectAtIndex:(currentImageIndex-1)];
}
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:kTransitionDuration];
currentImageIndex--;
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.containerView cache:YES];
if ([self.image2 superview] == NO) {
[self.image1 removeFromSuperview];
[self.containerView addSubview:self.image2];
} else {
[self.image2 removeFromSuperview];
[self.containerView addSubview:self.image1];
}
[UIView commitAnimations];
[self updateCurrentImageCounter];
}
- (void) curlToNext
{
if (currentImageIndex == ([self imageCount]-1)) return;
if ([self.image2 superview] == NO) {
self.image2.image = (UIImage*) [imageViews objectAtIndex:(currentImageIndex+1)];
} else {
self.image1.image = (UIImage*) [imageViews objectAtIndex:(currentImageIndex+1)];
}
currentImageIndex++;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:kTransitionDuration];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.containerView cache:YES];
if ([self.image2 superview] == NO) {
[self.image1 removeFromSuperview];
[self.containerView addSubview:self.image2];
} else {
[self.image2 removeFromSuperview];
[self.containerView addSubview:self.image1];
}
[UIView commitAnimations];
[self updateCurrentImageCounter];
}
I have
if ([self.image2 superview] == NO) {
In this line on 4 places in code problem.
The text I get is:
implicit conversion of 'int' to 'UIView' is disallowed with ARC
How can I avoid this??? Thanks.
you can replace your code on this if ([self.image2 superview] == nil)
You are comparing an UIView* with an integer (0) - of course you get a warning. Do you want to check whether the superview is nil? Then just do that:
if([self.image2 superview] == nil) { ... }

UIViewController autorotate some components?

I have a UIViewController that has an image view and a toolbar. I would like the toolbar to rotate, but the imageview to stay as it is. Is this possible?
Yes this is possible, but requires manual handling of rotate events.
In viewDidLoad, add
// store the current orientation
currentOrientation = UIInterfaceOrientationPortrait;
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector: #selector(receivedRotate:) name: UIDeviceOrientationDidChangeNotification object: nil];
if(currentOrientation != self.interfaceOrientation) {
[self deviceInterfaceOrientationChanged:self.interfaceOrientation];
}
and don't forget to deregister events when the controller is removed.
Then add a method for rotates:
// This method is called by NSNotificationCenter when the device is rotated.
-(void) receivedRotate: (NSNotification*) notification
{
NSLog(#"receivedRotate");
UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];
if(interfaceOrientation != UIDeviceOrientationUnknown) {
[self deviceInterfaceOrientationChanged:interfaceOrientation];
} else {
NSLog(#"Unknown device orientation");
}
}
and finally the rotate method
- (void)deviceInterfaceOrientationChanged:(UIInterfaceOrientation)interfaceOrientation {
if(interfaceOrientation == currentOrientation) {
NSLog(#"Do not rotate to current orientation: %i", interfaceOrientation);
} else if(interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
NSLog(#"Do not rotate to UIInterfaceOrientationPortraitUpsideDown");
} else if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
NSLog(#"Do not rotate to UIInterfaceOrientationLandscapeLeft");
} else {
if(!isRotating)
{
isRotating = YES;
if(currentOrientation == UIInterfaceOrientationPortrait && interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
NSLog(#"Rotate to landscape");
// rotate to right top corner
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
// do your rotation here
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(animationDoneShowCaption:finished:context:)];
[UIView commitAnimations];
} else if(currentOrientation == UIInterfaceOrientationLandscapeRight && interfaceOrientation == UIInterfaceOrientationPortrait) {
// etc
}
isRotating = NO;
} else {
NSLog(#"We are already rotating..");
}
}
currentOrientation = interfaceOrientation;
}
Note that I do not allow for rotates in some directions, you might.
In addition, you need to make your components resizable / able to rotate.
Edit Consider using block-based animations instead and set the isRotation = NO in the completion block.

iphone : Switching views like a picture book, problem with removeFromSuperView

Right I know how to do the pictue book effect but I struggling to remove the view
So page 1, I add the second page view via addSubview (via a swipe). I also increment a counter so I know what page I am on.
So how do I return to page 1? See I thought it would be self.view removeFromSuperview but that crashes when you try to go back to page 2
Code below
- (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {
if (recognizer.direction == UISwipeGestureRecognizerDirectionLeft) {
//NSLog(#"swipe right to left");
UniversalAppAppDelegate *appDelegate = (UniversalAppAppDelegate *)[[UIApplication sharedApplication] delegate];
PictureBookViewController *viewController2 =(PictureBookViewController *) [appDelegate getViewControllerForViewID:#"81"];
[UIView beginAnimations:Nil context:nil];
[UIView setAnimationDuration:0.6];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view.superview cache:YES];
self.viewController = viewController2;
self.viewController.pageNo = self.pageNo + 1;
[self.view addSubview:self.viewController.view];
[UIView commitAnimations];
[viewController2 release];
} else {
//NSLog(#"swipe left to right");
NSLog([NSString stringWithFormat:#"%d", self.pageNo]);
if (self.pageNo > 0) {
[UIView beginAnimations:Nil context:nil];
[UIView setAnimationDuration:0.6];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view.superview cache:YES];
//self.viewController = viewController2;
//self.viewController.pageNo = self.pageNo - 1;
//[self.view addSubview:self.viewController.view];
[self.view removeFromSuperview];
//[self.view addSubview:self.viewController.view];
[UIView commitAnimations];
}
}
}
Update:
Each view has its own view controllers.
You want to remove your viewController's view, not the container's view.
[self.viewController.view removeFromSuperview];
This seems to work and not crash? I am now convinced it right. I just seem to need a way of removing the last added subview. My first view is not the superview
- (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {
if (recognizer.direction == UISwipeGestureRecognizerDirectionLeft) {
//NSLog(#"swipe right to left");
UniversalAppAppDelegate *appDelegate = (UniversalAppAppDelegate *)[[UIApplication sharedApplication] delegate];
PictureBookViewController *viewController2 =(PictureBookViewController *) [appDelegate getViewControllerForViewID:#"82"];
[UIView beginAnimations:Nil context:nil];
[UIView setAnimationDuration:0.6];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view.superview cache:YES];
self.viewController = viewController2;
self.viewController.pageNo = self.pageNo + 1;
self.viewController.lastViewController = self;
[self.view addSubview:self.viewController.view];
[UIView commitAnimations];
[viewController2 release];
} else {
//NSLog(#"swipe left to right");
NSLog([NSString stringWithFormat:#"%d", self.pageNo]);
if (self.pageNo > 0) {
[UIView beginAnimations:Nil context:nil];
[UIView setAnimationDuration:0.6];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view.superview cache:YES];
self.pageNo --;
self.view = self.viewController.view;
[self.view removeFromSuperview ];
self.view = self.lastViewController.view;
[UIView commitAnimations];
}
}
}

TTThumbView/TTPhotoView no autorotation

In my app I try to use the TTphotoView, so in a ViewController I push the TTphotoView with my navigationController like this:
if(self.photoViewController == nil {
PhotoViewController *viewController = [[PhotoViewController alloc] init];
self.photoViewController = viewController;
viewController.hidesBottomBarWhenPushed = YES;
[viewController release];
}
[self.navigationController pushViewController:self.photoViewController animated:YES];
[self.navigationController  dismissModalViewControllerAnimated:YES]
the problem is when the user rotate the device on the PhotoViewController nothing happen.
EDIT : I can't believe people didn't have the same problem. If someone use the photoView in his application with his own navigation and not the TTNavigation can he tell me how did he push the ViewController?
I had the same problem.
I don't know why but TTScrollView deviceOrientationDidChange method in three20 code is commented out! If you uncomment it, it will work.
See the code here: http://github.com/facebook/three20/blob/master/src/TTScrollView.m
Have you overridden your application's:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
and returned YES for the landscape orientations?
My comment for willcodejavaforfood, as I told you I can force by doing something like for example that but too many problem inside, and the PhotoViewController of three20 must do it by himself so I don't want that:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(receivedRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
}
-(void) receivedRotate: (NSNotification *) notification {
NSLog(#"ORIENTATION CHANGE");
UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];
if(interfaceOrientation == UIDeviceOrientationLandscapeRight) {
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration: 0.5f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
self.view.transform = CGAffineTransformIdentity;
self.view.transform = CGAffineTransformMakeRotation(-M_PI/2);
self.view.bounds = CGRectMake(0.0, 0.0, 480.0, 320.0);
self.view.center = CGPointMake(240.0f, 160.0f);
[UIView commitAnimations];
}
}