cocoaTouch/OverlayViewController.m
changeset 3385 361bd29293f4
parent 3364 e5403e2bf02c
child 3395 095273ad0e08
equal deleted inserted replaced
3384:7eb4707d43f0 3385:361bd29293f4
    27 	// Releases the view if it doesn't have a superview.
    27 	// Releases the view if it doesn't have a superview.
    28     [super didReceiveMemoryWarning];
    28     [super didReceiveMemoryWarning];
    29 	// Release any cached data, images, etc that aren't in use.
    29 	// Release any cached data, images, etc that aren't in use.
    30 }
    30 }
    31 
    31 
    32 /*
    32 -(void) didRotate:(NSNotification *)notification {	
    33 - (void)didRotate:(NSNotification *)notification {	
    33     UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
       
    34     CGRect rect = [[UIScreen mainScreen] bounds];
       
    35     
    34 	if (orientation == UIDeviceOrientationLandscapeLeft) {
    36 	if (orientation == UIDeviceOrientationLandscapeLeft) {
    35 	}
    37         [UIView beginAnimations:@"flip1" context:NULL];
    36     if (orientation == UIDeviceOrientationLandscapeRight) {
    38         [UIView setAnimationDuration:0.8f];
    37     }
    39         [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    38 	if (orientation == UIDeviceOrientationPortrait) {
    40         [[SDLUIKitDelegate sharedAppDelegate].uiwindow viewWithTag:SDL_VIEW_TAG].transform = CGAffineTransformMakeRotation(degreesToRadian(0));
    39 	}
    41         self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
    40     if (orientation == UIDeviceOrientationPortrait) {
    42         self.view.frame = CGRectMake(0, 0, rect.size.width, rect.size.height);
    41 	}
    43         [UIView commitAnimations];
    42 }
    44 	} else
    43 */
    45         if (orientation == UIDeviceOrientationLandscapeRight) {
       
    46             [UIView beginAnimations:@"flip2" context:NULL];
       
    47             [UIView setAnimationDuration:0.8f];
       
    48             [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
       
    49             [[SDLUIKitDelegate sharedAppDelegate].uiwindow viewWithTag:SDL_VIEW_TAG].transform = CGAffineTransformMakeRotation(degreesToRadian(180));
       
    50             self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
       
    51             self.view.frame = CGRectMake(0, 0, rect.size.width, rect.size.height);
       
    52             [UIView commitAnimations];
       
    53         }
       
    54 }
       
    55 
    44 
    56 
    45 -(void) viewDidLoad {
    57 -(void) viewDidLoad {
    46     /*
    58 
    47     [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];	
       
    48     [[NSNotificationCenter defaultCenter] addObserver:self
       
    49 							selector:@selector(didRotate:)
       
    50 							name:UIDeviceOrientationDidChangeNotification
       
    51 							object:nil];
       
    52     */
       
    53     isPopoverVisible = NO;
    59     isPopoverVisible = NO;
    54     self.view.alpha = 0;
    60     self.view.alpha = 0;
    55 
       
    56     // needed for rotation to work on os < 3.2
       
    57     self.view.center = CGPointMake(self.view.frame.size.height/2.0, self.view.frame.size.width/2.0);
    61     self.view.center = CGPointMake(self.view.frame.size.height/2.0, self.view.frame.size.width/2.0);
    58     self.view.transform = CGAffineTransformRotate(self.view.transform, (M_PI/2.0));
    62     
    59     self.view.frame = [[UIScreen mainScreen] applicationFrame];
       
    60     
    63     
    61     dimTimer = [[NSTimer alloc] initWithFireDate:[NSDate dateWithTimeIntervalSinceNow:6]
    64     dimTimer = [[NSTimer alloc] initWithFireDate:[NSDate dateWithTimeIntervalSinceNow:6]
    62                                         interval:1000
    65                                         interval:1000
    63                                           target:self
    66                                           target:self
    64                                         selector:@selector(dimOverlay)
    67                                         selector:@selector(dimOverlay)
    96 }
    99 }
    97 
   100 
    98 // draws the controller overlay after the sdl window has taken control
   101 // draws the controller overlay after the sdl window has taken control
    99 -(void) showMenuAfterwards {
   102 -(void) showMenuAfterwards {
   100     [[SDLUIKitDelegate sharedAppDelegate].uiwindow bringSubviewToFront:self.view];
   103     [[SDLUIKitDelegate sharedAppDelegate].uiwindow bringSubviewToFront:self.view];
   101 
   104     
       
   105     // need to split paths because iphone doesn't rotate (so we don't need to subscribe to any notification
       
   106     // nor perform engine actions when rotating
       
   107     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
       
   108         [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];	
       
   109         [[NSNotificationCenter defaultCenter] addObserver:self
       
   110                                                  selector:@selector(didRotate:)
       
   111                                                      name:@"UIDeviceOrientationDidChangeNotification"
       
   112                                                    object:nil];
       
   113         
       
   114         [self didRotate:nil];
       
   115     } else 
       
   116         self.view.transform = CGAffineTransformRotate(self.view.transform, (M_PI/2.0));
       
   117     
   102 	[UIView beginAnimations:@"showing overlay" context:NULL];
   118 	[UIView beginAnimations:@"showing overlay" context:NULL];
   103 	[UIView setAnimationDuration:1];
   119 	[UIView setAnimationDuration:1];
   104 	self.view.alpha = 1;
   120 	self.view.alpha = 1;
   105 	[UIView commitAnimations];
   121 	[UIView commitAnimations];
   106 }
   122 }