, iOS API, , iOS .
iOS iOS, ,
, , .
, setStatusBarOrientation
, , , , , , , , , .
:
setStatusBarOrientation: : . , supportedInterfaceOrientations 0
Application.FormFactor.Orientations := []; //the supportedInterfaceOrientations returns 0
App := TUIApplication.Wrap(TUIApplication.OCClass.sharedApplication);
win := TUIWindow.Wrap(App.windows.objectAtIndex(0));
App.setStatusBarOrientation(UIInterfaceOrientationLandscapeLeft);
, , , , - /, .
.., rootviewcontroller , .
, Delphi Application- > Orientation- > Enable custom rotation , , , , , rootViewcontroller , , , Viewcontroller - .
, , Viewcontroller , , .
rootviewcontroller, Viewcontrollers, , /, .
TL; DR
Uses: iOSapi.UIKit;
procedure ChangeiOSorientation(toOrientation: UIInterfaceOrientation;
possibleOrientations: TScreenOrientations);
var
win : UIWindow;
App : UIApplication;
viewController : UIViewController;
oucon: UIViewController;
begin
Application.FormFactor.Orientations := [];
App := TUIApplication.Wrap(TUIApplication.OCClass.sharedApplication);
win := TUIWindow.Wrap(App.windows.objectAtIndex(0));
App.setStatusBarOrientation(toOrientation);
{After you have changed your statusbar orientation set the
Supported orientation/orientations to whatever you need}
Application.FormFactor.Orientations := possibleOrientations;
viewController := TUIViewController.Wrap(TUIViewController.alloc.init);
oucon := TUIViewController.Wrap(TUIViewController.alloc.init);
{Now we are creating a new Viewcontroller now when it is created
it will have to check what is the supported orientations}
oucon := win.rootViewController;
Win.setRootViewController(viewController);
Win.makeKeyAndVisible;
win.setRootViewController(oucon);
win.makeKeyAndVisible;
{And now we Display our original Content in a new Viewcontroller
with our new Supported orientations}
end;
, , ChangeiOSorientation(toOrientation,possibleOrientations)
, "",
ChangeiOSorientation(UIInterfaceOrientationPortrait,[TScreenOrientation.Portrait,TScreenOrientation.Landscape,TScreenOrientation.InvertedLandscape]);
- Delphi 10 Seattle
- iPhone 5 iOS 9.0
- PA 17.0
- Xcode 7.1
- iPhoneOS 9.1 SDK