cocoaTouch/OverlayViewController.m
changeset 3395 095273ad0e08
parent 3385 361bd29293f4
child 3405 8fdb08497bf1
equal deleted inserted replaced
3394:47b51e22e670 3395:095273ad0e08
    30 }
    30 }
    31 
    31 
    32 -(void) didRotate:(NSNotification *)notification {	
    32 -(void) didRotate:(NSNotification *)notification {	
    33     UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
    33     UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
    34     CGRect rect = [[UIScreen mainScreen] bounds];
    34     CGRect rect = [[UIScreen mainScreen] bounds];
    35     
    35     CGRect usefulRect = CGRectMake(0, 0, rect.size.width, rect.size.height);
    36 	if (orientation == UIDeviceOrientationLandscapeLeft) {
    36     UIView *sdlView = [[SDLUIKitDelegate sharedAppDelegate].uiwindow viewWithTag:SDL_VIEW_TAG];
    37         [UIView beginAnimations:@"flip1" context:NULL];
    37     
    38         [UIView setAnimationDuration:0.8f];
    38     [UIView beginAnimations:@"rotation" context:NULL];
    39         [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    39     [UIView setAnimationDuration:0.8f];
    40         [[SDLUIKitDelegate sharedAppDelegate].uiwindow viewWithTag:SDL_VIEW_TAG].transform = CGAffineTransformMakeRotation(degreesToRadian(0));
    40     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    41         self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
    41 	switch (orientation) {
    42         self.view.frame = CGRectMake(0, 0, rect.size.width, rect.size.height);
    42         case UIDeviceOrientationLandscapeLeft:
    43         [UIView commitAnimations];
    43             sdlView.transform = CGAffineTransformMakeRotation(degreesToRadian(0));
    44 	} else
    44             self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
    45         if (orientation == UIDeviceOrientationLandscapeRight) {
    45             HW_setLandscape(YES);
    46             [UIView beginAnimations:@"flip2" context:NULL];
    46             break;
    47             [UIView setAnimationDuration:0.8f];
    47         case UIDeviceOrientationLandscapeRight:
    48             [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    48             sdlView.transform = CGAffineTransformMakeRotation(degreesToRadian(180));
    49             [[SDLUIKitDelegate sharedAppDelegate].uiwindow viewWithTag:SDL_VIEW_TAG].transform = CGAffineTransformMakeRotation(degreesToRadian(180));
       
    50             self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
    49             self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
    51             self.view.frame = CGRectMake(0, 0, rect.size.width, rect.size.height);
    50             HW_setLandscape(YES);
    52             [UIView commitAnimations];
    51             break;
    53         }
    52         case UIDeviceOrientationPortrait:
    54 }
    53             sdlView.transform = CGAffineTransformMakeRotation(degreesToRadian(270));
    55 
    54             self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(0));
       
    55             HW_setLandscape(NO);
       
    56             break;
       
    57         case UIDeviceOrientationPortraitUpsideDown:
       
    58             sdlView.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
       
    59             self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(180));
       
    60             HW_setLandscape(NO);
       
    61             break;
       
    62         default:
       
    63             NSLog(@"warning - Unknown rotation status");
       
    64             break;
       
    65     }
       
    66     self.view.frame = usefulRect;
       
    67     sdlView.frame = usefulRect;
       
    68     [UIView commitAnimations];
       
    69 }
    56 
    70 
    57 -(void) viewDidLoad {
    71 -(void) viewDidLoad {
    58 
    72 
    59     isPopoverVisible = NO;
    73     isPopoverVisible = NO;
    60     self.view.alpha = 0;
    74     self.view.alpha = 0;