ios - How do I set orientation of a second UIWindow -


i have following code in main viewcontroller viewdidload function

window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]];   nav = [[navwithautorotateviewcontroller alloc] initwithrootviewcontroller:self];  [window addsubview:[nav view]]; [window makekeyandvisible];   [[self navigationcontroller] setnavigationbarhidden:yes]; 

my ipad app set work in landscape mode , i'm using new window show quicklook document , allowing nav bar provide button , save options document. main problem new uiwindow orientation doesn't match main applications uiwindow.

i have custom uinavigationcontroller above called navwithautorotatecontroller , here code controller.

-(id)init {     if(self)     { //        _supportedinterfaceorientatoin = uiinterfaceorientationmasklandscape; //        _orientation = uiinterfaceorientationlandscapeleft;     }       return self; } - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil {     self = [super initwithnibname:nibnameornil bundle:nibbundleornil];     if (self) {         // custom initialization     }     return self; }  - (void)viewdidload {     [super viewdidload];     // additional setup after loading view. }  - (void)didreceivememorywarning {     [super didreceivememorywarning];     // dispose of resources can recreated. }  - (bool)shouldautorotate {     return yes; }  - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)tointerfaceorientation {     return yes; }  -(nsuinteger)supportedinterfaceorientations {     return uiinterfaceorientationmasklandscapeleft; }   // tell system initial orientation want have - (uiinterfaceorientation)preferredinterfaceorientationforpresentation {     return uiinterfaceorientationmasklandscape; } 

i think have solution. problem seems in assignment of uiviewcontroller rootviewcontroller in uiwindow.

if assume can use same view controller primary uiwindow using, , add things subviews of new uiwindow, there orientation issues.

to solve this, did following:

uiwindow *newwindow = [[uiwindow alloc] initwithframe: [uiapplication sharedapplication].keywindow.frame]; newwindow.windowlevel = uiwindowlevelstatusbar+1; // can use view controller instantiated xib or storyboard here if want. // don't use view controller set uiwindow's rootviewcontroller. uiviewcontroller *newviewcontroller = [[uiviewcontroller alloc] init]; newwindow.rootviewcontroller = newviewcontroller; [newwindow makekeyandvisible]; // add new uiwindow. can use new uiviewcontroller's view: [newviewcontroller.view addsubview: mycontentview]; // or add subview of uiwindow: - either works. [newwindow addsubview: mycontentview]; 

doing way seems have solved weird issues around rotation. hope helps.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -