Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 5    Views: 1232

NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
03/08/14 03:36 PM (10 years ago)

How to allow only landscape rotations for iPhone iOS 7 App (non-tabbed)

I have checked lots of the forum links and online, but can't seem to find the right info as most is really old and previous to BTv3. (Seems BT_viewController.m is where I need to edit.) My other app I am working on is Portrait only so no problems there ;) However would like to have a different iPhone iOS7 app that is ONLY Landscape. Xcode 5.0- Target General Settings of Landscape Left and Landscape Right have no effect. Figure will need to edit BT_Layout files. (A Non-Tabbed App) App Flow: Splash Screen -> Menu Screen -> Content Screens (all of which can be tuned for Landscape only) For example Splash screen uses image 568x320 that will work well for 3.5" and 4" ==================== Thought about a brute force work-around to lock in portrait and face images by pre-rotating to 320x568 that look right when user turns phone. This will work for Splash and Content, but figured all of the menu screens would be rotated wrong :( Especially since I would probably would like to use the Buzz Carousel in Landscape mode. I have not purchased the plugin yet, but figured it would not let me configure in landscape if the screen was actually in Portrait mode. Thanks!
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
03/08/14 03:45 PM (10 years ago)
There are very few plugins that don't work in landscape. The carousel looks great in landscape.
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
03/08/14 04:03 PM (10 years ago)
Right dead ways to force landscape orientation find the last method in your app delegate.m file it looks like this. //supportedInterfaceOrientations is needed for iOS 6 > -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ [BT_debugger showIt:self message:[NSString stringWithFormat:@"supportedInterfaceOrientationsForWindow %@", @""]]; /* This method only used on iOS 6.0 >. The UIApplicationClass did not handle the supportedInterfaceOrientationsForWindow method prior to iOS 6. */ //allow / dissallow rotations, asume we do NOT allow rotations... BOOL canRotate = FALSE; //appDelegate if([self.rootDevice isIPad]){ //iPads always support rotations... canRotate = TRUE; }else{ //should we allow rotations on all devices? if([self.rootApp.jsonVars objectForKey:@"allowRotation"]){ if([[self.rootApp.jsonVars objectForKey:@"allowRotation"] isEqualToString:@"allDevices"]){ canRotate = TRUE; } } } //bitwise OR operator... NSUInteger mask = 0; mask |= UIInterfaceOrientationMaskPortrait; if(canRotate){ mask |= UIInterfaceOrientationMaskLandscapeLeft; mask |= UIInterfaceOrientationMaskLandscapeRight; mask |= UIInterfaceOrientationMaskPortraitUpsideDown; } //return... return mask; } You want it always in landscape nothings else. Well let's strip everything out and just leave that //supportedInterfaceOrientations is needed for iOS 6 > -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ [BT_debugger showIt:self message:[NSString stringWithFormat:@"supportedInterfaceOrientationsForWindow %@", @""]]; NSUInteger mask = 0; mask |= UIInterfaceOrientationMaskLandscapeLeft; mask |= UIInterfaceOrientationMaskLandscapeRight; //return... return mask; } Voila nice and easy
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
03/08/14 04:12 PM (10 years ago)
In my quest to get code that has less lines but is still readable let's go for this -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; } That makes sense doesn't it supported interface orientations return landscape left or landscape right
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
03/09/14 08:54 AM (10 years ago)
Kittsy -Thanks!! This works awesome. Splash screen now works only in landscape yet still enables user to orient device to left or right. (Really appreciate the second post to show next step to clearer code.) Now I am off to the BT market to get the Buzz Carousel so I can get add a cool main menu :)
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
03/09/14 09:16 AM (10 years ago)
Cool happy apping
 

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.