iphone - Rotating a View in iOS causes UIImageView height issues -


i have been writing app ios, , trying implement landscape views. trying support both ios 5 , ios 6, have autolayout disabled. when rotate landscape, layout loades correctly. rotate landscape, , when rotate portrait, uiimageview containing logo stretches underneath button , label.

from viewcontroller.m:

@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 correct xib based on orientation , 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 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 , 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;          */     } } 

from appdelegate.m:

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions {     self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]];     // override point 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; } 

check autoresizingmask property of uiimageview. should uiviewautoresizingflexibleheight first.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -