The context of this question is iOS 8, Xamarin and PlayN with an application in landscape mode only.
I used to rescale my application in FinishedLaunching based on UIScreen.MainScreen.Bounds to adapt to different screen sizes.With the iOS 8 SDK, the semantics of the API changed. Previously, UIScreen was not orientation dependent. Here the code for previous SDK that used to work fine:
public partial class AppDelegate : UIApplicationDelegate
{
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
app.SetStatusBarStyle (UIStatusBarStyle.LightContent, false);
IOSPlatform.Config config = new IOSPlatform.Config ();
config.orients = IOSPlatform.SupportedOrients.LANDSCAPES;
IOSPlatform.register (app, config);
System.Drawing.RectangleF bounds = UIScreen.MainScreen.Bounds;
// Flip width and height when in landscape for iOS SDK before iOS 8
float screenHeight = bounds.Width;
float screenWidth = bounds.Height;
float heightRatio = screenHeight / MyGame.HEIGHT;
float widthRatio = screenWidth / MyGame.WIDTH;
float ratio = (heightRatio < widthRatio ? heightRatio : widthRatio);
PlayN.graphics ().rootLayer ().setScale (ratio, ratio);
MyGame game = new MyGame ();
PlayN.run (game);
return true;
}
}
With iOS 8 SDK, UIScreen is now interface oriented. I thought just removing the code flipping height and width above would be sufficient to migrate. But this is not the case. The UI is moved to the right by approximatively one third of the screen and is distorted.
Context :
- Xcode 6 beta 6
- Xamarin.iOS 7.9.4.29
- 1.8.5
Any advice to migrate this code would be appreciated.
The solution is to migrate to PlayN 1.9 alpha 1 which is now based on RoboVM instead of Xamarin.
In Info.plist.xml:
and the java code launching the game (no need for C# anymore)