mirror of
https://github.com/apache/cordova-plugin-statusbar.git
synced 2025-04-21 21:26:23 +08:00
parent
6552bddfd1
commit
f0031ca2b4
@ -70,6 +70,10 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@interface CDVStatusBar () <
|
||||||
|
UIScrollViewDelegate>
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation CDVStatusBar
|
@implementation CDVStatusBar
|
||||||
|
|
||||||
- (id)settingForKey:(NSString*)key
|
- (id)settingForKey:(NSString*)key
|
||||||
@ -120,6 +124,16 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
|||||||
if ([self settingForKey:setting]) {
|
if ([self settingForKey:setting]) {
|
||||||
[self setStatusBarStyle:[self settingForKey:setting]];
|
[self setStatusBarStyle:[self settingForKey:setting]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// blank scroll view to intercept status bar taps
|
||||||
|
self.webView.scrollView.scrollsToTop = NO;
|
||||||
|
UIScrollView *fakeScrollView = [[UIScrollView alloc] initWithFrame:UIScreen.mainScreen.bounds];
|
||||||
|
fakeScrollView.delegate = self;
|
||||||
|
fakeScrollView.scrollsToTop = YES;
|
||||||
|
[self.viewController.view addSubview:fakeScrollView]; // Add scrollview to the view heirarchy so that it will begin accepting status bar taps
|
||||||
|
[self.viewController.view sendSubviewToBack:fakeScrollView]; // Send it to the very back of the view heirarchy
|
||||||
|
fakeScrollView.contentSize = CGSizeMake(UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height * 2.0f); // Make the scroll view longer than the screen itself
|
||||||
|
fakeScrollView.contentOffset = CGPointMake(0.0f, UIScreen.mainScreen.bounds.size.height); // Scroll down so a tap will take scroll view back to the top
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _ready:(CDVInvokedUrlCommand*)command
|
- (void) _ready:(CDVInvokedUrlCommand*)command
|
||||||
@ -411,4 +425,12 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#pragma mark - UIScrollViewDelegate
|
||||||
|
|
||||||
|
- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView
|
||||||
|
{
|
||||||
|
[self.webView stringByEvaluatingJavaScriptFromString:@"var evt = document.createEvent(\"Event\"); evt.initEvent(\"statusTap\",true,true); window.dispatchEvent(evt);"];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user