Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 3    Views: 47

JimmySaver
Aspiring developer
Profile
Posts: 187
Reg: Apr 09, 2012
location unknow...
5,870
08/04/13 01:59 AM (12 years ago)

Navbar Repeats in Landscape Orientation

Morning buzztouchers, I'm wondering if anyone has a workaround to the following problem.. I've used the excellent (and succinct) tutorial by MGoBlue for almost all of my iPhone apps in order to replace the Navbar. All of these apps have been fixed to portrait. The latest one I'm building requires free orientation and I'm hitting on a "snag". On orientation to landscape, the navbar repeats itself a little (i.e. I have an image in the middle of the navbar file and this is repeated (only a little) on the right hand side of the screen (this is addition to the bar itself reducing by 11px, but I can understand the reason for this). I *think* there'd be two possible solutions (neither of which I cant find mention of in the forum). The first would be to have the navbar background and the central image as separate files which are called programatically. Any pointers on achieving this would be greatly appreciated (even if it's on a screen by screen basis, this would still solve the problem I suppose). The second solution I can think of is to add an additional navbar image file, i.e. nav-landscape.png and [email protected] (in addition to the nav.png and [email protected] files). Could this work too? Any and all assistance and comments are welcome!
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/04/13 03:41 AM (12 years ago)
I think Jeff uses oversized images for that; 2048 x 2048 and such... so that regardless if it's portrait or landscape, the image covers the intended areas. I'm guessing the NavBar image would be for landscape, and can be used for either...? Or am I mis-reading the question...? Cheers! -- Smug
 
JimmySaver
Aspiring developer
Profile
Posts: 187
Reg: Apr 09, 2012
location unknow...
5,870
like
08/04/13 06:30 AM (12 years ago)
Hi Smug, Thanks for the reply. I dont think you;re misreading the question and I've taken something from this - the nav bar size is not constrained programtically when using MGoBlue's guide and the nav bar can be any size you like (and will be displayed as such). With this in mind, I created a 480x44 nav.png file and this yields no repeats. So it can be a workaround in some circumstances. The issue I have is that the nav.png file contains a centralised logo. So in a 480x44 (as opposed to a 320x44 file) the logo displays fine in portrait but is off-centre in landscape mode. I still think that there *should* be an option to call a nav-landscape.png. My last alternative is to think about how to add the logo over the top of the nav bar (programatically). Even if this is per-screen, it's still a solution I suppose.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
08/04/13 03:30 PM (12 years ago)
The 'end all, be all' solution would be to create a NavBar image for each possible orientation/device, and provide a means to put it there. That can be done relatively easy, but you have to modify the code to do it. To decide which device you're using, this code can work: if([appDelegate.rootApp.rootDevice isIPad]){ [BT_debugger showIt:self theMessage:@"it is an iPad"]; }else { if([UIScreen mainScreen].bounds.size.height == 568) { [BT_debugger showIt:self theMessage:@"it is an iPhone5"]; }else{ [BT_debugger showIt:self theMessage:@"it is an iPhone 3/4"]; } } And of course you would need another test for orientation as well... if (UIInterfaceOrientationIsLandscape(orientation)) { // landscape } else { // portrait } It might seem a bit 'rube goldberg' at first, but I think if you created some variables that held the size and orientation, you could write a quick routine that can test and apply the correct image without too much trouble... Cheers! -- Smug
 

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.