Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 5    Views: 618

WebNevees
Code is Art
Profile
Posts: 206
Reg: Oct 28, 2012
KL
11,660
12/20/12 07:04 AM (13 years ago)

Change Background Image based on device orientation / rotation

Hi, I'm looking for a way to change the background image of any screen (especially the menu buttons screen) whenever the device orientation changes. both for iOS and Android. This way I wouldn't need to lock my orientation... So I'll put 4 images for the background, 2 for landscape (large and small device versions) and 2 for portrait (again large and small). Thanks for the hinters fellow Buzztouchers!
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
12/20/12 12:45 PM (13 years ago)
found this online. if you know abit of code you maybe able to tweek this? "Put this code in your ViewController.m - (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation) fromInterfaceOrientation { // Set UIWebView Background Image if (UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation)) { // code for Portrait orientation self->webView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"ui-background-portrait.png"]]; } if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) { // code for landscape orientation self->webView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"ui-background-landscape.png"]]; } }"
 
WebNevees
Code is Art
Profile
Posts: 206
Reg: Oct 28, 2012
KL
11,660
like
12/21/12 02:45 AM (13 years ago)
Thanks. I'll work on it, although I am not well-versed in Objective C!
 
juansezoh
Code is Art
Profile
Posts: 25
Reg: Nov 01, 2012
Medellín
2,200
like
02/19/13 11:22 PM (12 years ago)
Someone knows how to do this in android?. Thanks
 
OrchardApps
Code is Art
Profile
Posts: 115
Reg: Jan 11, 2012
Brisbane austra...
5,850
like
05/31/13 05:26 AM (12 years ago)
Hiya, Did you figure this out. It's driving me a little crazy. I'm using the BTA Design Menu plugin. At this point I'll have to lock the device and because of the nature of the app I really don't want to do that. Any pointers would be appreciated. Chris
 
WebNevees
Code is Art
Profile
Posts: 206
Reg: Oct 28, 2012
KL
11,660
like
05/31/13 10:53 AM (12 years ago)
Hi, Actually at the time I didn't and I just locked the app. Both in Android and in iOS. But I'll look into it in a couple days. Please post me a reminder if I don't in a week. Thanks.
 

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.