mirror of
https://github.com/apache/cordova-plugin-statusbar.git
synced 2024-10-06 00:22:08 +08:00
fix(iOS): Inline code to find the webview's scrollView (#272)
Currently this works because of a category extension that adds a `scrollView` method to every UIView instance, but that causes issues for SwiftUI so we want to remove that extension from cordova-ios. Since we do need to be able to look up the scrollView in this plugin, we can just define a private local method that does the same thing in a way that doesn't pollute global UIKit classes. Ref: https://github.com/apache/cordova-ios/pull/1400
This commit is contained in:
parent
6132b4474c
commit
5492147ab7
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#import "CDVStatusBar.h"
|
#import "CDVStatusBar.h"
|
||||||
#import <objc/runtime.h>
|
#import <objc/runtime.h>
|
||||||
|
#import <objc/message.h>
|
||||||
#import <Cordova/CDVViewController.h>
|
#import <Cordova/CDVViewController.h>
|
||||||
|
|
||||||
static const void *kHideStatusBar = &kHideStatusBar;
|
static const void *kHideStatusBar = &kHideStatusBar;
|
||||||
@ -143,9 +144,9 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
|||||||
|
|
||||||
setting = @"StatusBarDefaultScrollToTop";
|
setting = @"StatusBarDefaultScrollToTop";
|
||||||
if ([self settingForKey:setting]) {
|
if ([self settingForKey:setting]) {
|
||||||
self.webView.scrollView.scrollsToTop = [(NSNumber*)[self settingForKey:setting] boolValue];
|
[self webViewScrollView].scrollsToTop = [(NSNumber*)[self settingForKey:setting] boolValue];
|
||||||
} else {
|
} else {
|
||||||
self.webView.scrollView.scrollsToTop = NO;
|
[self webViewScrollView].scrollsToTop = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// blank scroll view to intercept status bar taps
|
// blank scroll view to intercept status bar taps
|
||||||
@ -462,6 +463,17 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
|||||||
[[NSNotificationCenter defaultCenter]removeObserver:self name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
|
[[NSNotificationCenter defaultCenter]removeObserver:self name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (UIScrollView *)webViewScrollView
|
||||||
|
{
|
||||||
|
SEL scrollViewSelector = NSSelectorFromString(@"scrollView");
|
||||||
|
|
||||||
|
if ([self.webView respondsToSelector:scrollViewSelector]) {
|
||||||
|
return ((id (*)(id, SEL))objc_msgSend)(self.webView, scrollViewSelector);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#pragma mark - UIScrollViewDelegate
|
#pragma mark - UIScrollViewDelegate
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user