Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ViewController orientation change
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- // Do any additional setup after loading the view from its nib.
- Storage *strg = [Storage sharedStorage];
- if ([strg.orient intValue] == 2)
- {
- [[UIApplication sharedApplication] setStatusBarOrientation:
- UIInterfaceOrientationLandscapeRight];
- UIScreen *screen = [UIScreen mainScreen];
- CGFloat screenWidth = screen.bounds.size.width;
- CGFloat screenHeight = screen.bounds.size.height;
- UIView *navView = [[self navigationController] view];
- navView.bounds = CGRectMake(0, 0, screenHeight, screenWidth);
- navView.transform = CGAffineTransformIdentity;
- navView.transform = CGAffineTransformMakeRotation(1.57079633);
- navView.center = CGPointMake(screenWidth/2.0, screenHeight/2.0);
- [UIView commitAnimations];
- }
- if ([strg.orient intValue] == 1)
- {
- [[UIApplication sharedApplication] setStatusBarOrientation:
- UIInterfaceOrientationLandscapeLeft];
- UIScreen *screen = [UIScreen mainScreen];
- CGFloat screenWidth = screen.bounds.size.width;
- CGFloat screenHeight = screen.bounds.size.height;
- UIView *navView = [[self navigationController] view];
- navView.bounds = CGRectMake(0, 0, screenHeight, screenWidth);
- navView.transform = CGAffineTransformIdentity;
- navView.transform = CGAffineTransformMakeRotation(4.71238898);
- navView.center = CGPointMake(screenWidth/2.0, screenHeight/2.0);
- [UIView commitAnimations];
- }
- }
- [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(deviceDidRotateSelector:) name: UIDeviceOrientationDidChangeNotification object: nil];
- -(void)deviceDidRotateSelector:(NSNotification*) notification {
- // respond to rotation here
- }
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- //Return YES for supported orientations
- return YES;
- }
Add Comment
Please, Sign In to add comment