Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

iOS Orientation Fix #1081

Merged
merged 5 commits into from Jan 26, 2013

Conversation

Projects
None yet
4 participants
Contributor

RayBatts commented Dec 14, 2012

Luckily, not too much changed to fix this.

CreateFramebuffer() was determining the orientation of the screen by which orientations were supported, rather than the orientation the device was currently in. This caused applications that support multiple orientations to display incorrectly at times. I used the iOS OrientationSample in the Samples folder to fix and debug this.

Let me know if there are any issues with this. This fix should have only touched iOS specific code.

RayBatts added some commits Dec 14, 2012

@RayBatts RayBatts Fixed bug that was preventing the framebuffer from being created in t…
…he correct size on iOS.
56b7f3f
@RayBatts RayBatts Fixes orientation issues for devices that support multiple orientatio…
…ns, as well as a single (such as landscape only).
9d775c4
@RayBatts RayBatts Using a view's ContentScaleFactor rather than Window.Screen.Scale sin…
…ce there can be a race condition of a null window.
1ade724
@RayBatts RayBatts Preventing KeyboardInputViewControllers from returning an orientation…
… that the application does not support. (Which will throw an exception).
1839cc6
Member

Nezz commented Dec 16, 2012

Tested and haven't noticed anything (which is a good thing). Is there anything specific I should do to test?

Contributor

RayBatts commented Dec 17, 2012

@Nezz - Testing starting up in different supported orientations and cycling between them to make sure that there were no unintended side effects.

Also testing KeyboardInputViewControllers in different situations would be helpful.

Owner

tomspilman commented Dec 28, 2012

Can someone else give these changes a test?

Member

Nezz commented Dec 29, 2012

As for the KeyboardInputViewController thing, the current approach is to enable all orientations in the Info.plist as MonoGame manages them the XNA way. I had to do that because GameCenter requires portrait orientation as of iOS 6.0.

Contributor

RayBatts commented Jan 5, 2013

I'd like to see another person test this out before pulling it in.

@RayBatts RayBatts Merge branch 'develop3d' into iOSOrientationFix
Conflicts:
	MonoGame.Framework/iOS/iOSGameView.cs
cd7a146
Owner

tomspilman commented Jan 24, 2013

Anyone else have time to test this?

Contributor

totallyeviljake commented Jan 25, 2013

last night I got MayanTiles up on iOS using the latest MG dev3d branch. It is a portrait only game. On the iPad it started in landscape mode and did not switch out. I will try this fix to see if that is fixed. I won't rule out my own failure, but MT works fine on Windows Phone 7 - its already on the marketplace. We also have another game Tiles of India that switches between orientations for different puzzle screens. I'll try that one next. That'll be tonight though, sorry - no mac in the office.

Contributor

totallyeviljake commented Jan 25, 2013

I ran your code and didn't see anything adverse. My test is simple though - just launch the game and swap screens around. I found my fail on the orientation not adjusting for me, but your code was invariant in this, so that's a good sign that it had no adverse side effects for me.

Contributor

totallyeviljake commented Jan 26, 2013

further testing on iPad G1 and iPhone 4 devices is successful. So far I have not seen any adverse problems with this PR.

vote +1 from me.

Owner

tomspilman commented Jan 26, 2013

Thanks for testing it.

I'm going to merge it. If something goes wrong i'm sure we'll hear about it.

@tomspilman tomspilman added a commit that referenced this pull request Jan 26, 2013

@tomspilman tomspilman Merge pull request #1081 from SickheadGames/iOSOrientationFix
iOS Orientation Fix
14fc338

@tomspilman tomspilman merged commit 14fc338 into MonoGame:develop3d Jan 26, 2013

Contributor

totallyeviljake commented Jan 27, 2013

I am seeing some odd behavior with Tiles of india. While I can request the orientation change, and effect it by reorienting the device manually, it does not force the orientation change when I request it.

So I start the game in portrait, select a puzzle that is in landscape, keep the ipad in portrait orientation, and see the puzzle render in portrait instead of landscape. Then I manually reorient the device, it switches the orientation, but I don't get a new drawing surface with new dimensions for landscape mode.

Contributor

totallyeviljake commented Jan 28, 2013

ugh. DisplayOrientation.Default = 1 ?? Really! That totally messed up our screen twist logic. XNA has that as ZERO.

Contributor

totallyeviljake commented Jan 28, 2013

okay so Rays work is working out well. the orientation switching is working, albeit not automatically. I have to reorient the ipad to make the orientation flip. That's probably a nuance of the hardware/iOS. Good job Ray!

Contributor

totallyeviljake commented Jan 28, 2013

funny thing - iPhone 4 running 6.0.1 appears to crash somewhere inside of monotouch when I reorient the device for landscape mode. weird. iPad G1 works great. iPad is running iOS 5.1.1

Member

Nezz commented Jan 28, 2013

iOS 5 and 6 use different methods for handling orientations. You should check them. They are commented to indicate what's used in iOS 5 and what's used in iOS 6.

Contributor

totallyeviljake commented Jan 28, 2013

@Nezz can you point me in the general direction of where these comments are? I am just using the plain XNA interface to set the supported orientations which should affect the orientation switch without any fancy magic on my end.

Member

Nezz commented Jan 28, 2013

In MonoGame.Framework/iOS/iOSGameViewController.cs
search for #region Autorotation for iOS 5 or older

@RayBatts RayBatts deleted the SickheadGames:iOSOrientationFix branch May 30, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment