Permalink
Browse files

Merge pull request #3 from shrtlist/master

Check for valid device interface orientation, default to portrait if face up or face down.
  • Loading branch information...
2 parents 2fc4349 + c3e6eaf commit c038546865ec79fa803fba17d9e29ad6fcf1af31 Sergey Vinogoradov committed May 8, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 AMTextFieldNumberPad.m
@@ -257,8 +257,16 @@ - (void)changeButtonParams {
- (void)orientationDidChange:(NSNotification *)theNotification {
isRotating = TRUE;
-
- isPortrait = UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation);
+
+ NSUInteger orientation = [UIDevice currentDevice].orientation;
+
+ if (!UIDeviceOrientationIsValidInterfaceOrientation(orientation)) {
+ isPortrait = YES;
+ }
+ else {
+ isPortrait = UIDeviceOrientationIsPortrait(orientation);
+ }
+
buttonRectShow = (isPortrait) ? CGRectMake(0.00f, 427.00f, 105.00f, 53.00f) : CGRectMake(0.00f, 281.00f, 158.00f, 39.00f);
buttonRectHide = (isPortrait) ? CGRectMake(0.00f, 644.00f, 105.00f, 53.00f) : CGRectMake(0.00f, 443.00f, 158.00f, 39.00f);

0 comments on commit c038546

Please sign in to comment.