Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non-rotating background image on orientation change on iOS

I'm developing an iphone app and it allows for both portrait and landscape orientation. However, I have a background image, in an UIImageView, which should not be rotated when the orientation changes. I've searched around and experimented with some options, but have not found a satisfactory solution. I tried using transforms in willAnimateRotationToInterfaceOrientation: but it makes the image move during rotation, and doesn't look good. I would like it to remain stationary.

Any help appreciated.

like image 503
Patrick Pijnappel Avatar asked Nov 27 '25 15:11

Patrick Pijnappel


1 Answers

Maybe try this:

YourAppDelegate *appDel = [UIApplication sharedApplication].delegate;
[appDel.window insertSubview:yourImageView atIndex:appropriateIndex];

as your appDelegate.window doesn't care about the current device orientation it might work out as a solution. I just tried adding a UIImageView to the appDel.window in the

didFinishLaunchingWithOptions

method, and as expected, it does not rotate with the above uiviewcontroller.view

Of course you could also try addSubview:

like image 57
pmk Avatar answered Nov 29 '25 08:11

pmk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!