![]() |
[FMX] Ändern der FormOrientation per Code
Hallo zusammen,
ich baue gerade eine App in der nur ein Form im Querformat angezeigt werden soll. In der Projektdatei steht
Delphi-Quellcode:
Soweit so gut, Querformat ist geblockt. Jetzt zeige ich eine Form die im Querformat erscheinen soll an:
Application.FormFactor.Orientations := [TFormOrientation.Portrait, TFormOrientation.InvertedPortrait];
Delphi-Quellcode:
Im frmQuer.OnClose:
Application.FormFactor.Orientations := [TFormOrientation.Landscape, TFormOrientation.InvertedLandscape];
frmQuer.Show;
Delphi-Quellcode:
Wie kann ich dem Gerät denn mitteilen dass es die neue Orientierung übernehmen soll, sprich sofort zeichnen. Aktuell muss das Gerät gedreht werden, dann wird die neue Orientierung angenommen und der Rest geblockt.
Application.FormFactor.Orientations := [TFormOrientation.Portrait, TFormOrientation.InvertedPortrait];
Gruss |
AW: [FMX] Ändern der FormOrientation per Code
Hallo Darlo,
versuch mal das
Delphi-Quellcode:
Bin mir nicht mehr sicher obs auch eine Drehung des Gerätes erwartet.
// Sets the possible Screen orientations (Portrait, Landscape, InvertedPortrait, InvertedLandscape);
procedure Form_Orientation_Set2(const orientSet : TScreenOrientations ); var ScreenService: IFMXScreenService; begin if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, IInterface(ScreenService)) then begin ScreenService.SetScreenOrientation(orientSet); end; end; Rollo |
AW: [FMX] Ändern der FormOrientation per Code
Hallo Rollo,
danke für Deine Antwort. Leider wird hierbei die View auch nicht automatisch gedreht. Ich habe, zumindest für iOS, hier eine Lösung gefunden: ![]() Gruss |
AW: [FMX] Ändern der FormOrientation per Code
Was passiert denn wenn du nur eine Möglichkeit hier setzt ?
Delphi-Quellcode:
oder
Application.FormFactor.Orientations := [TFormOrientation.Landscape];
Delphi-Quellcode:
Application.FormFactor.Orientations := [TFormOrientation.Portrait];
Wenn es z.b. Portait ist und du setzt Landscape in die möglichen Orientazions, erzwingt man damit nicht die Drehung auch ohne dass das Gerät sich dreht ? Das gibt es in den D.P.F. Controls:
Delphi-Quellcode:
Rollo// ------------------------------------------------------------------------------ function ScreenForceRotate( IfOrientationNotIn: TScreenOrientation ): boolean; const ConvOri: array [TScreenOrientation] of NativeUInt = ( UIDeviceOrientationPortrait, UIDeviceOrientationLandscapeRight, UIDeviceOrientationPortraitUpsideDown, UIDeviceOrientationLandscapeLeft ); var w: UIWindow; v: UIView; // ScreenService : IFMXScreenService; MainRroot : UIViewController; Orientations: TFormOrientations; // CurOrientation: TScreenOrientation; begin Orientations := Application.FormFactor.Orientations; try (* if TPlatformServices.Current.SupportsPlatformService( IFMXScreenService, IInterface( ScreenService ) ) then CurOrientation := ScreenService.GetScreenOrientation else CurOrientation := TScreenOrientation.soPortrait; Result := CurOrientation <> IfOrientationNotIn; *) Result := true; // CurOrientation <> IfOrientationNotIn; if Result then begin MainRroot := GetSharedApplication.keyWindow.rootViewController; Application.FormFactor.Orientations := [TScreenOrientation.Portrait, TScreenOrientation.Landscape, TScreenOrientation.InvertedPortrait, TScreenOrientation.InvertedLandscape]; GetSharedApplication.keyWindow.setRootViewController( nil ); // application.ProcessMessages; GetSharedApplication.setStatusBarOrientation( ConvOri[IfOrientationNotIn] ); TUIDevice.Wrap( TUIDevice.OCClass.currentDevice ).performSelector( sel_getUid( 'setOrientation:' ), ( TNSNumber.Wrap( TNSNumber.OCClass.numberWithUnsignedInt( ConvOri[IfOrientationNotIn] ) ) as ILocalObject ).GetObjectID, 0 ); w := GetSharedApplication.keyWindow; if w.subviews.count > 0 then begin v := TUIView.Wrap( w.subviews.objectAtIndex( 0 ) ); v.removeFromSuperview; w.insertSubview( v, 0 ); end; GetSharedApplication.keyWindow.setRootViewController( MainRroot ); GetSharedApplication.keyWindow.rootViewController.didRotateFromInterfaceOrientation( ConvOri[IfOrientationNotIn] ); end; finally Application.FormFactor.Orientations := Orientations; end; end; |
AW: [FMX] Ändern der FormOrientation per Code
Leider unter iOS nicht.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:42 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz