The Hacker’s Corner » Blog Archive » Modifying FMX_Platform_iOS.pas to support surface mainWindow and add d

        Here are the steps that I use in order to surface a couple of things that some of my custom iOS components and apps need.
  These modifications are not supported by anyone. Except maybe me. You apply them entirely at your own risk.
  Modify FMX_Platform_iOS.pas on your MAC as below. It’s typically located in the /Developer/Embarcadero/fmi directory.
  CAUTION: Save a copy of FMX_Platform_iOS.pas FIRST!
CAUTION: Any update of XE2 will delete your changes, so keep this file around if you have to redo the changes.
  …
  unit FMX_Platform_iOS;
  …
  interface
  …
  // TUIViewController and TUIWindow declarations moved from implementation to interface section
  type
{ TUIViewController }
  TUIViewController = objcclass(UIViewController)
private
public
function shouldAutorotateToInterfaceOrientation(AinterfaceOrientation: UIInterfaceOrientation): Boolean; override;
procedure didReceiveMemoryWarning; override;
procedure didAnimateFirstHalfOfRotationToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation); override;
procedure didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation); override;
end;
  { TUIWindow }
  TUIWindow = objcclass(UIWindow)
protected
public
Text: UITextField;
mainView: UIView;
mainController: TUIViewController;
end;
  // mainWindow moved from implementation to interface section
// currentOrientation added to give current device orientation
// supportsPortrait etc added. You simply change these in your app code to False if not needed
  var
mainWindow: TUIWindow;
currentOrientation : UIInterfaceOrientation;
supportsPortrait : Boolean = True;
supportsPortraitUpsideDown : Boolean = True;
supportsLandscapeRight : Boolean = True;
supportsLandscapeLeft : Boolean = True;
  implementation
  …
  function TUIViewController.shouldAutorotateToInterfaceOrientation(
AinterfaceOrientation: UIInterfaceOrientation): Boolean;
begin
Result := ((AinterfaceOrientation = UIInterfaceOrientationLandscapeRight) and supportsLandscapeRight) or
((AinterfaceOrientation = UIInterfaceOrientationLandscapeLeft) and supportsLandscapeLeft) or
((AinterfaceOrientation = UIInterfaceOrientationPortrait) and supportsPortrait) or
((AinterfaceOrientation = UIInterfaceOrientationPortraitUpsideDown) and supportsPortraitUpsideDown);
  if Result then
currentOrientation := AinterfaceOrientation;
end;
  This entry was posted on Monday, May 7th, 2012 at 10:55 am and is filed under Delphi XE2, FireMonkey, RAD Studio XE2, iOS, iPhone. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
3 Responses to “Modifying FMX_Platform_iOS.pas to support surface mainWindow and add device orientation support”Olecramoak Says:
  @Anders: what does it do exactly? Could not figure out..
  is it to avoid device rotation? Intersting that compiled XE2 app ignores rotation preferences from Xcode. Does this override that?
  I read somewhere that Apple is not a fan of non-rotateble apps and it might get rejected for it. But what do we know, I guess each case is avaliated individually by them.
Anders Ohlsson Says:
  DOH! I can’t believe I forgot to include the implementation part as well.
  shouldAutorotateToInterfaceOrientation has to be changed of course.
  Blog edited to reflect all changes…
Anders Ohlsson Says:
  And yes, the default behaviour is the same - all rotations are supported. If you set a few to False, then the UI won’t rotate to those.
  You don’t have to support all 4 rotations at all. Typically you support at least 2. I can’t see why you wouldn’t support Portrait AND PortraitUpsideDown if you support one of them, and likewise, I can’t see why you wouldn’t support LandscapeRight AND LandscapeLeft if you support one of them.
  My first app - my analog clock - only supports Portrait. If I ever update it again, I’ll probably support all UI rotations with proper scaling. The MathViz update will only support Landscap (Left/Right) going forward, simply because the controls constrict the middle of the screen too much. At least the way I designed it.
引文来源   The Hacker’s Corner ? Blog Archive ? Modifying FMX_Platform_iOS.pas to support surface mainWindow and add device orientation support
        


        



        




        
  
  



        
          
            
            评论这张
          
        


          
            
               The Hacker’s Corner raquo; Blog Archive raquo; Modifying FMX_Platform_iOS.pas to support surface mainWindow and add d - yyimen - yyimen的博客
            
            转发至微博
          
        

        
          
            
               The Hacker’s Corner raquo; Blog Archive raquo; Modifying FMX_Platform_iOS.pas to support surface mainWindow and add d - yyimen - yyimen的博客
            
            转发至微博
          
        
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值