Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 2    Views: 70

AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
02/25/15 10:13 AM (9 years ago)

Working-IOS Portrait lock, option for landscape in defined screens

I realised that whilst I wanted to force portrait at the startup and keep the menu's in potrait, I would like a couple of plugins in the app to work in portrait, e.g. Location Map, RD RSS. Update - I've seen some posts from a year back, which I think are BT2. I worked through the threads and found the solution
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
02/26/15 12:29 PM (9 years ago)
Taken from the following post by @Absentia : http://www.buzztouch.com/forum/thread.php?tid=7FEB35DBB58D059354CEC04&currentPage=2 I tidied it up a little to just show the working result, which I have tested in BT 3.0 Type canRotate into the Xcode search tool - then replace every occurrence of "canRotate = TRUE" with "canRotate = FALSE” Next go to BT_Config>appDelegate.m and find the supportedInterfaceOrientation code way down at the bottom and replace the entire method with this, but remember to edit it so that it has your app delegate name (in this example, using ltcptest_appDelegate.m.), and the nav bar text of the screen you want to be in landscape - //***************************** //supportedInterfaceOrientationsForWindow... -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"supportedInterfaceOrientationsForWindow %@", @""]]; //allow / dissallow rotations BOOL canRotate = FALSE; //appDelegate ltcptest_appDelegate *appDelegate = (ltcptest_appDelegate *)[[UIApplication sharedApplication] delegate]; if ([[BT_strings getStyleValueForScreen:self.rootApp.currentScreenData nameOfProperty:@"navBarTitleText" defaultValue:@""] isEqualToString:@"sfedona"]){ canRotate = TRUE; }else{ if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) { canRotate = FALSE; }else{ //should we prevent rotations on small devices? if([appDelegate.rootApp.jsonVars objectForKey:@"allowRotation"]){ if([[appDelegate.rootApp.jsonVars objectForKey:@"allowRotation"] isEqualToString:@"largeDevicesOnly"]){ NSLog(@"%@", @"SHOULD NOT ROTATE"); canRotate = FALSE; } } } } NSUInteger mask = 0; mask |= UIInterfaceOrientationMaskPortrait; if(canRotate){ mask |= UIInterfaceOrientationMaskLandscapeLeft; mask |= UIInterfaceOrientationMaskLandscapeRight; mask |= UIInterfaceOrientationMaskPortraitUpsideDown; } return mask; } //**************************************************************************** // Next, go to BT_Layout>BT_navController.m and add this code - -(BOOL)shouldAutorotate { return [[self.viewControllers lastObject] shouldAutorotate]; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation]; } // Finally, go to the plugin screen that you will be going BACK to from your landscape screen and add this code up at the top, underneath the snthesize code (if you don't do this, when you go back the previous screen will appear in landscape mode as well) - -(BOOL)shouldAutorotate { return YES; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; }
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
02/26/15 12:31 PM (9 years ago)
If you back out of the landscaped screen, there are some scenario's where it stays in landscape, but it mostly works.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.