Created
November 21, 2012 04:57
-
-
Save ChrisRisner/4123116 to your computer and use it in GitHub Desktop.
iOS Day 16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(BOOL) shouldAutorotate { | |
return NO; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(NSUInteger)supportedInterfaceOrientations | |
{ | |
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskPortrait; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface ViewController : UIViewController | |
@property (weak, nonatomic) IBOutlet UILabel *lblInfo; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view, typically from a nib. | |
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; | |
if (orientation == UIInterfaceOrientationLandscapeLeft) { | |
NSLog(@"Landscape left"); | |
self.lblInfo.text = @"Landscape left"; | |
} else if (orientation == UIInterfaceOrientationLandscapeRight) { | |
NSLog(@"Landscape right"); | |
self.lblInfo.text = @"Landscape right"; | |
} else if (orientation == UIInterfaceOrientationPortrait) { | |
NSLog(@"Portrait"); | |
self.lblInfo.text = @"Portrait"; | |
} else if (orientation == UIInterfaceOrientationPortraitUpsideDown) { | |
NSLog(@"Upside down"); | |
self.lblInfo.text = @"Upside down"; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { | |
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) { | |
NSLog(@"Landscape left"); | |
self.lblInfo.text = @"Landscape left"; | |
} else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) { | |
NSLog(@"Landscape right"); | |
self.lblInfo.text = @"Landscape right"; | |
} else if (toInterfaceOrientation == UIInterfaceOrientationPortrait) { | |
NSLog(@"Portrait"); | |
self.lblInfo.text = @"Portrait"; | |
} else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { | |
NSLog(@"Upside down"); | |
self.lblInfo.text = @"Upside down"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment