SwapViewController.m
上传用户:jjjjag8
上传日期:2017-04-17
资源大小:1443k
文件大小:2k
源码类别:

iPhone

开发平台:

MultiPlatform

  1. #import "SwapViewController.h"
  2. @implementation SwapViewController
  3. @synthesize landscape;
  4. @synthesize portrait;
  5. @synthesize landscapeFooButton;
  6. @synthesize portraitFooButton;
  7. @synthesize landscapeBarButton;
  8. @synthesize portraitBarButton;
  9. - (void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
  10. duration:(NSTimeInterval)duration {
  11. if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
  12. {
  13. self.view = self.portrait;
  14. self.view.transform = CGAffineTransformIdentity;
  15. self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(0));
  16. self.view.bounds = CGRectMake(0.0, 0.0, 300.0, 480.0);
  17. }
  18. else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
  19. {
  20. self.view = self.landscape;
  21. self.view.transform = CGAffineTransformIdentity;
  22. self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
  23. self.view.bounds = CGRectMake(0.0, 0.0, 460.0, 320.0);
  24. }
  25. else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
  26. {
  27. self.view = self.portrait;
  28. self.view.transform = CGAffineTransformIdentity;
  29. self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(180));
  30. self.view.bounds = CGRectMake(0.0, 0.0, 300.0, 480.0);
  31. }
  32. else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
  33. {
  34. self.view = self.landscape;
  35. self.view.transform = CGAffineTransformIdentity;
  36. self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
  37. self.view.bounds = CGRectMake(0.0, 0.0, 460.0, 320.0);
  38. }
  39. }
  40. -(IBAction)buttonPressed:(id)sender {
  41. if (sender == portraitFooButton || sender == landscapeFooButton)
  42. {
  43. portraitFooButton.hidden = YES;
  44. landscapeFooButton.hidden = YES;
  45. }
  46. else
  47. {
  48. portraitBarButton.hidden = YES;
  49. landscapeBarButton.hidden = YES;
  50. }
  51. }
  52. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  53. return YES;
  54. }
  55. - (void)didReceiveMemoryWarning {
  56. [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
  57. // Release anything that's not essential, such as cached data
  58. }
  59. - (void)dealloc {
  60. [landscape release];
  61. [portrait release];
  62. [landscapeFooButton release];
  63. [portraitFooButton release];
  64. [landscapeBarButton release];
  65. [portraitBarButton release];
  66. [super dealloc];
  67. }
  68. @end