objective c - Rotation with Different Layouts - iOS 4 -


the following 2 layouts want have in application. nice if when application switches portrait landscape keeps uilabels, bools, , other objects. because buttons situated differently cannot have portrait view autoresize on auto rotate. want implement own rotation lock using bool , button on top right.

i thought using -(void)orientationchanged:(nsnotification )notification presentmodalviewcontroller these didn't copy on objects , seemed cause more harm , didn't appear work properly.

thanks help!

portrait xib landscape xib

attempted solutions:

i added landscape view viewcontroller, having both views in view controller. linked file's owner under uiview *landscapeview added in @interface section of viewcontroller. added [self.view addsubview:landscapeview] viewdidload method. added piece of code:

- (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation {     if (orientationlock)         return no;     else {         if (interfaceorientation == uiinterfaceorientationportrait) {             [landscapeview sethidden:yes];             //[self.view sethidden:no]; removed         } else {             //[self.view sethidden:yes]; removed             [landscapeview sethidden:no];         }         return yes;     } } 

however not correct solution. when run simulator , rotate it, screen not placed.

bad image

all things(your instance variables values) remains same when device changes orientation. if have 1 viewcontroller , showing both orieantation in same can manage this. suggest create 2 uiviews in nib file way can things want.hope understand talking about.let me know if need help.

here modified code

- (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { if (orientationlock)     return no; else {     if (interfaceorientation == uiinterfaceorientationportrait) {         [landscapeview sethidden:yes];      } else {          [landscapeview sethidden:no];     }     return yes; } } 

Comments