You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2018/12/27 15:27:34 UTC

[GitHub] chrisetler commented on issue #306: InApp browser not support in iPhone X devices

chrisetler commented on issue #306: InApp browser not support in iPhone X devices
URL: https://github.com/apache/cordova-plugin-inappbrowser/issues/306#issuecomment-450171898
 
 
   I found a solution but it only works with the toolbar positioned at the bottom.
   
   It works by not hardcoding the height of the "blur" UItoolbar added behind the status bar to 20 and instead getting the value from the device, and by keeping a reference to the toolbar so that when the device orientation changes we can detect if the toolbar was hidden (as it is on the iPhone X) and hide our blur accordingly. 
   
   In CordovaInAppBrowser.h add the following to the CDVInAppBrowserNavigationController interface:
   
       @private
       UIToolbar* bgToolbar;
   
   In CordovaInAppBrowser.m in viewDidLoad use this:
   
   - (void) viewDidLoad {
    
       CGRect statusBarFrame = [self invertFrameIfNeeded:[UIApplication sharedApplication].statusBarFrame];
   
   //don't hardcode the height
   //    statusBarFrame.size.height =  STATUSBAR_HEIGHT;
       
       
       // simplified from: http://stackoverflow.com/a/25669695/219684
       bgToolbar = [[UIToolbar alloc] initWithFrame:statusBarFrame];
       bgToolbar.barStyle = UIBarStyleDefault;
       [bgToolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
       [self.view addSubview:bgToolbar];
       
       //set the statusbar height    
       [self fixStatusBar];
       
       [super viewDidLoad];
   }
   
   
   Directly below the viewDidLoad method add this:
   
   - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
       [coordinator animateAlongsideTransition:nil completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
           // fix height after orientation change
            [self fixStatusBar];
       }];
   }
   
   -(void)fixStatusBar {
       CGRect statusBarFrame = [self invertFrameIfNeeded:[UIApplication sharedApplication].statusBarFrame];
       if([UIApplication sharedApplication].isStatusBarHidden) {
           statusBarFrame.size.height = 0;
       }
       
       [bgToolbar setFrame:statusBarFrame];
   
   
       
   }

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org