Note that there are some explanatory texts on larger screens.

plurals
  1. PORotating a View in iOS causes UIImageView height issues
    primarykey
    data
    text
    <p>I have been writing an app for iOS, and I am trying to implement landscape views. I am trying to support both iOS 5 and iOS 6, so I have autolayout disabled. When I rotate to landscape, the layout loades correctly. Then I rotate to landscape, and when I rotate back to portrait, the UIImageView containing my logo stretches underneath my button and another label.</p> <p>From ViewController.m:</p> <pre><code>@interface ViewController () - (IBAction)showMenu:(id)sender; @end @implementation ViewController @synthesize start, menuButton, vector_status, login_status, items, recordLength, countdown, change_name, iapi, running, timeOver, setupDone, dfm, motionmanager, locationManager, recordDataTimer, timer, testLength, expNum, sampleInterval, sessionName,geoCoder,city,country,address,dataToBeJSONed,elapsedTime,recordingRate, experiment,firstName,lastInitial,userName,useDev,passWord,session_num,managedObjectContext,dataSaver,x,y,z,mag,image ; // displays the correct xib based on orientation and device type - called automatically upon view controller entry -(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { if([UIDevice currentDevice].userInterfaceIdiom==UIUserInterfaceIdiomPad) { if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) { [[NSBundle mainBundle] loadNibNamed:@"ViewController~landscape_iPad" owner:self options:nil]; [self viewDidLoad]; } else { [[NSBundle mainBundle] loadNibNamed:@"ViewController_iPad" owner:self options:nil]; [self viewDidLoad]; } } else { if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) { [[NSBundle mainBundle] loadNibNamed:@"ViewController~landscape_iPhone" owner:self options:nil]; [self viewDidLoad]; } else { [[NSBundle mainBundle] loadNibNamed:@"ViewController_iPhone" owner:self options:nil]; [self viewDidLoad]; } } } // pre-iOS6 rotating options - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } // iOS6 rotating options - (BOOL)shouldAutorotate { return YES; } // iOS6 interface orientations - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; } - (void)viewDidLoad { [super viewDidLoad]; UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)]; [start addGestureRecognizer:longPress]; recordLength = 10; countdown = 10; useDev = TRUE; self.navigationItem.rightBarButtonItem = menuButton; iapi = [iSENSE getInstance]; [iapi toggleUseDev: useDev]; running = NO; timeOver = NO; setupDone = NO; if (useDev) { expNum = DEV_DEFAULT_EXP; } else { expNum = PROD_DEFAULT_EXP; } dfm = [[DataFieldManager alloc] init]; //[dfm setEnabledField:YES atIndex:fACCEL_Y]; motionmanager = [[CMMotionManager alloc] init]; userName = @"sor"; passWord = @"sor"; firstName = @"No Name"; lastInitial = @"Provided"; [self login:@"sor" withPassword:@"sor"]; if (managedObjectContext == nil) { managedObjectContext = [(AppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext]; } // DataSaver from Data_CollectorAppDelegate if (dataSaver == nil) { dataSaver = [(AppDelegate *) [[UIApplication sharedApplication] delegate] dataSaver]; NSLog(@"Datasaver Details: %@", dataSaver.description); NSLog(@"Current count = %d", dataSaver.count); } } - (void) viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; if (self.isMovingToParentViewController == YES) { change_name = [[CODialog alloc] initWithWindow:self.view.window]; change_name.title = @"Enter First Name and Last Initial"; [change_name addTextFieldWithPlaceholder:@"First Name" secure:NO]; [change_name addTextFieldWithPlaceholder:@"Last Initial" secure:NO]; UITextField *last = [change_name textFieldAtIndex:1]; [last setDelegate:self]; [change_name addButtonWithTitle:@"Done" target:self selector:@selector(changeName)]; [change_name showOrUpdateAnimated:YES]; NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; BOOL x1 = [prefs boolForKey:@"X"]; BOOL y1 = [prefs boolForKey:@"Y"]; BOOL z1 = [prefs boolForKey:@"Z"]; BOOL mag1 = [prefs boolForKey:@"Magnitude"]; if (x) x = x1; if (y) y = y1; if (z) z = z1; if (mag) mag = mag1; [self willRotateToInterfaceOrientation:(self.interfaceOrientation) duration:0]; NSLog(@"Frog FROG FROG"); /*[image setAutoresizesSubviews:YES]; image.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; */ } } </code></pre> <p>From AppDelegate.m:</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil]; } else { self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil]; } UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:self.viewController]; navigation.navigationBar.barStyle = UIBarStyleBlackOpaque; self.window.rootViewController = navigation; NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; [prefs setBool:YES forKey:@"Y"]; self.viewController.setupDone = YES; [self.window makeKeyAndVisible]; return YES; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload