This is an automated email from the ASF dual-hosted git repository. dpogue pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cordova-ios.git
The following commit(s) were added to refs/heads/master by this push: new 538fe8e9 fix(catalyst): Fix content behind titlebar (#1517) 538fe8e9 is described below commit 538fe8e92fdc13ae5eac6d09edbc5222c87251e3 Author: Darryl Pogue <dar...@dpogue.ca> AuthorDate: Tue Dec 24 22:41:22 2024 -0800 fix(catalyst): Fix content behind titlebar (#1517) Closes GH-1491. --- CordovaLib/Classes/Public/CDVPlugin.m | 8 ++------ CordovaLib/Classes/Public/CDVViewController.m | 26 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/CordovaLib/Classes/Public/CDVPlugin.m b/CordovaLib/Classes/Public/CDVPlugin.m index a2da3b86..2a657703 100644 --- a/CordovaLib/Classes/Public/CDVPlugin.m +++ b/CordovaLib/Classes/Public/CDVPlugin.m @@ -21,7 +21,6 @@ #import <Cordova/CDVPlugin+Resources.h> #import "CDVPlugin+Private.h" #import <Cordova/CDVViewController.h> -#include <objc/message.h> @implementation UIView (org_apache_cordova_UIView_Extension) @@ -29,12 +28,9 @@ - (UIScrollView*)scrollView { - SEL scrollViewSelector = NSSelectorFromString(@"scrollView"); - - if ([self respondsToSelector:scrollViewSelector]) { - return ((id (*)(id, SEL))objc_msgSend)(self, scrollViewSelector); + if ([self respondsToSelector:@selector(scrollView)]) { + return [self performSelector:@selector(scrollView)]; } - return nil; } diff --git a/CordovaLib/Classes/Public/CDVViewController.m b/CordovaLib/Classes/Public/CDVViewController.m index 8cf9f248..a30671da 100644 --- a/CordovaLib/Classes/Public/CDVViewController.m +++ b/CordovaLib/Classes/Public/CDVViewController.m @@ -17,10 +17,10 @@ under the License. */ +#import <TargetConditionals.h> #import <AVFoundation/AVFoundation.h> #import <Foundation/Foundation.h> #import <WebKit/WebKit.h> -#import <objc/message.h> #import <Cordova/CDVAppDelegate.h> #import <Cordova/CDVPlugin.h> @@ -373,6 +373,30 @@ static UIColor* defaultBackgroundColor(void) { -(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; + +#if TARGET_OS_MACCATALYST + BOOL hideTitlebar = [self.settings cordovaBoolSettingForKey:@"HideDesktopTitlebar" defaultValue:NO]; + if (hideTitlebar) { + UIWindowScene *scene = self.view.window.windowScene; + if (scene) { + scene.titlebar.titleVisibility = UITitlebarTitleVisibilityHidden; + scene.titlebar.toolbar = nil; + } + } else { + // We need to fix the web content going behind the title bar + self.webView.translatesAutoresizingMaskIntoConstraints = NO; + [self.webView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor].active = YES; + [self.webView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor].active = YES; + [self.webView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor].active = YES; + [self.webView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor].active = YES; + + if ([self.webView respondsToSelector:@selector(scrollView)]) { + UIScrollView *scrollView = [self.webView performSelector:@selector(scrollView)]; + scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } + } +#endif + [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVViewDidAppearNotification object:nil]]; } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org