Jump to content
Calum Anderstrem

SafeAreaInsets Not Returning Safe Area on App Start; iPhone SE, 7 & 8

Recommended Posts

Hi,

 

The following code is used in an app to retrieve the safe area on iOS:

 

  function GetSafeAreaLayout: TRectF;
  var
    App: UIApplication;
    Win: UIWindow;
    Guide: UILayoutGuide;
  begin
    App := TUIApplication.Wrap (TUIApplication.OCClass.sharedApplication);
    Win := TUIWindow.Wrap (App.windows.objectAtIndex (0));
    Guide := Win.safeAreaLayoutGuide;
    Result := Guide.layoutFrame.ToRectF;
  end;

 

It is triggered in Resize, and worked for all iPhones when compiled under RAD 11.1. However, compiling under 11.2 and 11.3 patch 1, while the above function completes successfully on iPhone SE, 7 & 8, Result.Top returns as 0 when the app first starts (i.e. causes app to overlay system menu at top of phone). Either calling the function again after app start, or re-orientating the phone fixes the issue. This start-up problem does not happen on the iPhoneX.

 

Has anyone else encountered this issue and know of a fix, or is there a better, more reliable way to access the safe area?

 

Please accept my thanks in advance.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×