force app orientation to landscape in code - firemonkey

I'm building a multi-device application in C++ in Rad Studio Rio (10.3.2). The primary target is an iPhone. I'd like to have a button click that forces the app to landscape regardless of the phones actual orientation.
How can I do this? I'm looking for something like this:
Form1->Orientation = Landscape;
I know I can force the app to be portrait or landscape at design time: http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Application_Orientation but that is NOT what I want. I want to do it in my code at run time.
I can write code to change forms at runtime (e.g. make a "portrait" version of my form and a "landscape" version of my form and switch between them) but I'm hoping there is a code solution to let me use my one form and force it into landscape when i want.
thanks,
russ

Related

Xamarin iOS Splash Screen

Windows 10, Visual Studio 2019 (16.5.4).
I've been following this example:
https://learn.microsoft.com/en-us/xamarin/ios/app-fundamentals/images-icons/launch-screens?tabs=windows
Which is fairly straightforward. My splash screen is simply a blue background with my logo in the centre. However, I cannot work out how to centralise the logo on every iOS device and both portrait and landscape.
Do I have to create a different Asset or LaunchScreen.storyboard for every device?
The way I am familiar with that you can create a responsive design in iOS is to use the concept of AutoLayout.
But before you start that you should be aware of the basics of designing in iOS
Goodluck
Feel free to get back if you have queries
I cannot work out how to centralise the logo on every iOS device and both portrait and landscape.
In the designer you can grab the dot in the centre of the view and then drag it to the vertical or horizontal lines:
Check https://learn.microsoft.com/en-us/xamarin/ios/user-interface/designer/designer-auto-layout#center-constraints

Oreo - View layout management has changed?

Don't flame me but prior to Oreo I used to put view in a static and keep it switching from fragments and it worked pretty well. In onCreate I simply check if the value of view is not null and in that case I was not inflating. It allowed me to do long task in a fragment in an async and switch to another fragment waiting for the async to complete.
It still works the same way with O except when I rotate the device. In that case I get a blank screen: no layout, no buttons, no text, etc.
I've read https://developer.android.com/about/versions/oreo/android-8.0-changes but didn't find anything.
Do you have an idea to fix this without changing it all?
From the way I understand it. if the Rotation is locked to portrait mode, rotating the device won't force it into landscape mode if portrait mode is locked.
Check out the following post:
android-p-feature-spotlight-rotation-can-temporarily-locked-landscape-changes
Just as annoying as Android Oreo, and unlike most OEM versions of Android I've used. There are new APIs for screen rotation in Android P so it's not clear whether apps need to implement it to be able to lock to landscape from the first go.
Also check out the Android P preview for more info regarding the rotation changes, for some reason it appears to be relevant for the Android Oreo as well.
Feature Overview
Behaviour Overview

When I build my app my simulator looks different from my viewcontroller.xib

I was making a user interface using storyboards and when I built my app to see how it would look in the iOS simulator it didn't look like the viewcontroller in the storyboard (some of the buttons were moved around and I had to move one button way down so it was in the place i wanted it to be). Does anyone know why this is?
Yes, the reason is auto layout, it will automatically position elements on a relative basis depending on the device you're running.
You can turn autolayout off, or build for all devices at once and keep it on.
You may want to read iOS Auto Layout Demystified by Erica Sadun which goes in depth to the world of autolayout.

Metro style,how to make my screen compatible for landscape and portrait mode?

I am new to metro style app.I designed a normal page in visual studio 2012 ultimate in landscape mode using only drag and drop tools.I run this page using Emulator.It runs well in landscape mode.but In Portrait mode,the contents of the page is not fitted automatically.Even it is not allowed to scroll the screen to see all the contents in the page.
I want a design fits for all screen resolution and different orientation. what should i do?
If any tutorial available please provide the link.
Are you talking about Windows Phone or WinRT?
Either way, you need to handle the orientation change yourself.
If you're doing WinRT, start here:
Optimizing for both landscape and portrait
and if you're doing Windows Phone, start here:
How to: Handle Orientation Changes on Windows Phone

How can I detect landscape orientation in a WP7 template using SketchFlow?

I am using the official Windows Phone 7 SketchFlow template, based on the Windows Phone SDK. Is there any way to detect when the user has clicked the landscape orientation button in the player, and act accordingly? Specifically, I'd like to display completely different views depending on orientation. Thank you!
It looks like the portrait and landscape functionality is implemented with visual states. If you select the correct visual state and make your changes (such as showing different controls) it should work the way you want.

Resources