Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 22    Views: 78

feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
04/22/13 01:18 PM (12 years ago)

XIB button menu Ipad landscape only

Hello all I have been trying to make a very customized menu using the xib menu plug in. I Just want a landscape version of the menu for ipad. When I add buttons and background image to the xib and try to load it in the simulator it always loads in the portrait mode even when I flip the rotate left or right. I know this is probably a simple fix but I am not seeing something. I want ipad landscape only and im not sure how. Anyone out there have a quick fix?
 
MadRod
Aspiring developer
Profile
Posts: 1853
Reg: Apr 12, 2012
Lisbon
27,930
like
04/22/13 01:50 PM (12 years ago)
Hi, at the end of you appdelegate.m file, you'll find the orientations. Let me know if you can't find it. I'll find the post that explains it. Basically you can choose in what orientation the app loads. Cheers
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
04/22/13 02:05 PM (12 years ago)
Hey is this the code in the app delegate file? Im not sure what to change here. //supportedInterfaceOrientationsForWindow... -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"supportedInterfaceOrientationsForWindow %@", @""]]; //allow / dissallow rotations BOOL canRotate = TRUE; //appDelegate splatapp_appDelegate *appDelegate = (splatapp_appDelegate *)[[UIApplication sharedApplication] delegate]; if([appDelegate.rootApp.rootDevice isIPad]){ canRotate = TRUE; }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; } } } //bitwise OR operator... NSUInteger mask = 0; // UNCOMMENT THIS TO SUPPORT iOS 6 SCREEN ROTATAIONS mask |= UIInterfaceOrientationMaskPortrait; if(canRotate){ mask |= UIInterfaceOrientationMaskLandscapeLeft; mask |= UIInterfaceOrientationMaskLandscapeRight; mask |= UIInterfaceOrientationMaskPortraitUpsideDown; } return mask; }
 
MadRod
Aspiring developer
Profile
Posts: 1853
Reg: Apr 12, 2012
Lisbon
27,930
like
04/22/13 02:10 PM (12 years ago)
this is it, Where is says, uncomment, you uncomment, take the // out. mask |= UIInterfaceOrientationMaskPortrait; in this line, swap it to the direction you want it to open. Lets say landscape right, just change the MaskPortrait to MaskLandscapeRight. If you dont want the app to rotate, above where you see can rotate true, change it to FALSE. You follow? Tell me if you need help. Miguel
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
04/22/13 02:17 PM (12 years ago)
Got it now its in landscape mode which is what i was looking for but My xib menu is still showing the portrait xib not the landscape. In the xib ipad files there is the portrait and landscape views and I want the landscape to show not the portrait. Any ideas?
 
MadRod
Aspiring developer
Profile
Posts: 1853
Reg: Apr 12, 2012
Lisbon
27,930
like
04/22/13 02:24 PM (12 years ago)
Is it iphone or iPad?
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
04/22/13 02:25 PM (12 years ago)
ipad
 
MadRod
Aspiring developer
Profile
Posts: 1853
Reg: Apr 12, 2012
Lisbon
27,930
like
04/22/13 02:39 PM (12 years ago)
Its strange. I'm not with my computer so I can't help you much more. Maybe try deleting the XIB files for portrait... Cheers.
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/22/13 02:57 PM (12 years ago)
Are you saying when you open your app in landscape it shows the portrait view. Initially
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
04/22/13 03:06 PM (12 years ago)
Madrod When I delete the portrait xib the app crashes. Kittsy- When i open my xib menu home screen in landscape mode it only shows the portrait xib not the landscape xib. In xcode there are the two ipad xib screens in 1 file.
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/22/13 04:01 PM (12 years ago)
Put this at the end of view will appear if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { //if in Portrait Orientation if([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait) { self.view = iPadPortrait; } //if in Landscape Orientation if([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight) { self.view = iPadLandscape; } }
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
04/22/13 04:15 PM (12 years ago)
Kittsy it works!! Why do I have to add this code shouldnt this be in the plug in already? I wish I got to meet you at Buzzcon. You have saved me about 5 times now.
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/22/13 04:21 PM (12 years ago)
It goes down to testing, to be honest rotation is a royal pain in the arse with ios6, sometimes such a small bug just gets rolled over, there are a few ipad apps I've bought from the appstore which have this bug from bug companies also. My quest for perfection and prettiness has me doing research for this stuff. I'd have loved to get to america how far is it from florida, I'd have to justify the trip with a few theme parks
 
MadRod
Aspiring developer
Profile
Posts: 1853
Reg: Apr 12, 2012
Lisbon
27,930
like
04/22/13 04:23 PM (12 years ago)
lol.... theme parks. Gotta love them.
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
04/22/13 04:29 PM (12 years ago)
Florida has a few good ones! Hopefully well have another big meet up again soon.
 
mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
like
04/22/13 06:40 PM (12 years ago)
Feraco, Sorry for the delay, I was working all day in the ER and mondays are always crazy. I saw your email but didn't have time for lunch let alone time to sit down and try to help with this. I'm glad you got an answer from Kitsy. The fact it kept crashing when you deleted the portrait view makes sense. If you click on the landscape xib file then click on the portrait view and open the connections inspector (right facing arrow at top right) you'll see two items in the referencing outlets section connected to the file's owner: view and iPadPortrait. If you click on the landscape view you only see one: iPadLandscape. File's owner always needs to be connected to "view" and that is what is opened when the xib loads. In this case the portrait view loads. "iPadPortrait" and "iPadLandscape" are custom views I created. If you deleted the "view" reference for iPadPortrait and added it to iPadLandscape that would also have fixed the problem. Josh
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/23/13 02:09 AM (12 years ago)
If you added that line of code to the next update it will solve all the issues with rotation. The problem with changing the view the way you have suggested would mean that when the screen is opened in portrait the landscape view would show exactly the same problem as before but reversed. If you google this it's not a common problem unless the views are completely different think portrait version with header image and description text below, rotate and it then shows a full screen image in landscape. This is a xib problem, autolayout will make things easier once most people get ios6 or above. The reason native buzztouch apps works straight away is because they have bounds set so table views will automatically stretch across. The simple button menu works out the width of the view in view will appear method and then deals the buttons out like cards. UICollection view is an awesome peice of kit which would suit this style of button layout.
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
04/23/13 05:18 AM (12 years ago)
I love this plug in I am just having some first time trouble. I wanted to add more than 18 buttons. Here is the code in the .m file. I dont know what to change in the .h file. I also made changes to the json so it looks like this. Im not sure how to link the buttons I dragged into the xib to the code. Any pointers? buttonList = [[NSMutableArray alloc] init]; [buttonList addObject:@""]; [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen1" defaultValue:@""]]; [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen2" defaultValue:@""]]; [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen3" defaultValue:@""]]; [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen4" defaultValue:@""]]; [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen5" defaultValue:@""]]; [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen6" defaultValue:@""]]; [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen7" defaultValue:@""]]; [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen8" defaultValue:@""]]; [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen9" defaultValue:@""]]; [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen10" defaultValue:@""]]; [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen11" defaultValue:@""]]; [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen12" defaultValue:@""]]; [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen13" defaultValue:@""]]; [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen14" defaultValue:@""]]; [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen15" defaultValue:@""]]; [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen16" defaultValue:@""]]; [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen17" defaultValue:@""]]; [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen18"defaultValue:@""]]; } JSON {"itemId":"083BE0317ED8C6CE72D314A", "itemType":"JM_Xib_button_menu", "itemNickname":"Homescreen", "navBarTitleText":"Homescreen", "buttonScreen1":"D0DA77788947367CDC7C78B", "buttonScreen2":"2EC9F418DA1179D462C43C4", "buttonScreen3":"EBC199D89E794A55A5B197E", "buttonScreen4":"E3A64BABC7AF91F3DDBD552", "buttonScreen5":"C6B35F321BA7BC50D9FB37E", "buttonScreen6":"E7801A2FCC50C6600E32C38", "buttonScreen7":"DBD6C29FC1340A9BC2A7E00", "buttonScreen8":"93978E50DC7A0002188590E", "buttonScreen9":"F3697AC54BEDF849999FED9","buttonScreen10":"D0DA77788947367CDC7C78B", "buttonScreen11":"2EC9F418DA1179D462C43C4", "buttonScreen12":"EBC199D89E794A55A5B197E", "buttonScreen13":"E3A64BABC7AF91F3DDBD552", "buttonScreen14":"C6B35F321BA7BC50D9FB37E", "buttonScreen15":"E7801A2FCC50C6600E32C38", "buttonScreen16":"DBD6C29FC1340A9BC2A7E00", "buttonScreen17":"93978E50DC7A0002188590E","buttonScreen18":"93978E50DC7A0002188590E"}
 
mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
like
04/23/13 05:45 AM (12 years ago)
Kitsy, thanks! I'll get that added in an update! Feraco, You don't have to change anything in the .h file. A few of my apps also use more than 12 buttons. What I usually do to simplify things is add the screen ID directly to the .m file. For example, instead of: [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen18"defaultValue:@""]]; I would have this: [buttonList addObject:[BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"buttonScreen18"defaultValue:@"A779ED75470A032C55F0532"]]; That way you don't have to add it to the JSON data as well. The only thing you have to do is assign the proper tags to those buttons. Click on your new button and open the attributes inspector (looks like a shield top right, also shown in the plugin document). Scroll down until you see "tag" in the view section. In the tag box enter 13 for button 13, 14 for button 14, etc. That should do it. Josh
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
04/23/13 05:49 AM (12 years ago)
Great it works perfect I will give your plug in a positive rating. Thanks!!
 
OrchardApps
Code is Art
Profile
Posts: 115
Reg: Jan 11, 2012
Brisbane austra...
5,850
like
06/01/13 04:47 AM (12 years ago)
Hi guys, First of all - crazy good plugin. I'm so excited about it - solves a lot of my design issues. I am having problems with the ipad rotation. I have applied the code mentioned above to the JM_Xib_button_menu.m file, but still no luck. The problem: The view doesn't change when I change the orientation of my ipad. If I open in portrait it displays the correct view, but when I tilt to landscape it still shows the portrait view. If I hold the device in landscape and move away from the screen and then back it loads the correct landscape view - vice versa. So it seems to work only upon loading and it doesn't seem to update dynamically. Any help would be appreciated. Chris
 
OrchardApps
Code is Art
Profile
Posts: 115
Reg: Jan 11, 2012
Brisbane austra...
5,850
like
06/04/13 06:50 PM (12 years ago)
Hello. Me again. I am still having this problem. I have implemented what you guys have said so far and the orientation does work ... until I rotate the device once on the screen. I would really appreciate some help. Thanks Chris
 
MadRod
Aspiring developer
Profile
Posts: 1853
Reg: Apr 12, 2012
Lisbon
27,930
like
07/18/13 05:54 AM (12 years ago)
Hey, so THE MAN, Kittsy, solved me this problem as well. BT_tabBarController.m comment out lines 112 to 138 It works great. Thanks Cheers Miguel
 

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.