Advertisement
Guest User

Untitled

a guest
Jul 8th, 2013
182
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -(void)viewWillAppear:(BOOL)animated
  2. {
  3. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
  4. [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
  5.  
  6. }
  7.  
  8. -(void)viewWillDisappear:(BOOL)animated
  9. {
  10. [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
  11. }
  12.  
  13. -(void)checkOrientation
  14. {
  15. UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
  16. if (orientation == UIDeviceOrientationLandscapeLeft||orientation==UIDeviceOrientationLandscapeRight)
  17. {
  18. [tblView reloadData];
  19. // Set x coorinate of views you want to change
  20.  
  21. }
  22. else
  23. {
  24. [tblView reloadData];
  25. // Set x coordinates of views to initial x xoordinates.
  26.  
  27. }
  28.  
  29. }
  30.  
  31. - (void)receivedRotate:(NSNotification *)notification
  32. {
  33. [self checkOrientation];
  34. }
  35.  
  36. -(void)viewDidLoad
  37. {
  38. [self checkOrientation];
  39. }
Advertisement
RAW Paste Data Copied
Advertisement