Skip to content

Commit 91f1977

Browse files
authored
iOS: route status-bar taps into CN1 pointer handling (#4707)
1 parent f893e07 commit 91f1977

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

Ports/iOSPort/nativeSources/CodenameOne_GLViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163

164164
//ADD_INCLUDE
165165

166-
@interface CodenameOne_GLViewController : UIViewController<UIImagePickerControllerDelegate, MFMailComposeViewControllerDelegate,
166+
@interface CodenameOne_GLViewController : UIViewController<UIImagePickerControllerDelegate, MFMailComposeViewControllerDelegate, UIScrollViewDelegate,
167167
#ifdef CN1_USE_STOREKIT
168168
SKProductsRequestDelegate, SKPaymentTransactionObserver,
169169
#endif

Ports/iOSPort/nativeSources/CodenameOne_GLViewController.m

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ static void updateDisplayMetricsFromView(UIView *view) {
167167
displayHeight = (int)(view.bounds.size.height * scaleValue);
168168
}
169169
BOOL forceSlideUpField;
170+
static UIScrollView *cn1StatusBarTapProxy = nil;
170171

171172

172173
// 1 for portrait lock, and 2 for landscape lock
@@ -1896,6 +1897,7 @@ - (void)viewDidLoad {
18961897
[self.adView loadAd];
18971898
[super viewDidLoad];
18981899
updateDisplayMetricsFromView(self.view);
1900+
[self cn1InstallStatusBarTapProxy];
18991901
//replaceViewDidLoad
19001902
[self initGoogleConnect];
19011903
}
@@ -1908,11 +1910,42 @@ - (UIViewController *)viewControllerForPresentingModalView {
19081910
- (void)viewDidLoad {
19091911
[super viewDidLoad];
19101912
updateDisplayMetricsFromView(self.view);
1913+
[self cn1InstallStatusBarTapProxy];
19111914
//replaceViewDidLoad
19121915
[self initGoogleConnect];
19131916
}
19141917
#endif
19151918

1919+
- (void)cn1InstallStatusBarTapProxy {
1920+
if (cn1StatusBarTapProxy != nil) {
1921+
return;
1922+
}
1923+
cn1StatusBarTapProxy = [[UIScrollView alloc] initWithFrame:self.view.bounds];
1924+
cn1StatusBarTapProxy.delegate = self;
1925+
cn1StatusBarTapProxy.backgroundColor = [UIColor clearColor];
1926+
cn1StatusBarTapProxy.contentSize = CGSizeMake(1, 2);
1927+
cn1StatusBarTapProxy.contentOffset = CGPointMake(0, 1);
1928+
cn1StatusBarTapProxy.scrollsToTop = YES;
1929+
cn1StatusBarTapProxy.userInteractionEnabled = NO;
1930+
cn1StatusBarTapProxy.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
1931+
cn1StatusBarTapProxy.alpha = 0.0f;
1932+
[self.view addSubview:cn1StatusBarTapProxy];
1933+
}
1934+
1935+
- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView {
1936+
if (scrollView == cn1StatusBarTapProxy) {
1937+
int xArray[1];
1938+
int yArray[1];
1939+
xArray[0] = displayWidth / 2;
1940+
yArray[0] = 0;
1941+
pointerPressedC(xArray, yArray, 1);
1942+
pointerReleasedC(xArray, yArray, 1);
1943+
cn1StatusBarTapProxy.contentOffset = CGPointMake(0, 1);
1944+
return NO;
1945+
}
1946+
return YES;
1947+
}
1948+
19161949
- (void)initGoogleConnect {
19171950
#ifdef INCLUDE_GOOGLE_CONNECT
19181951
#ifndef GOOGLE_SIGNIN
@@ -2486,6 +2519,11 @@ - (void)dealloc
24862519
self.adView = nil;
24872520
#endif
24882521

2522+
#ifndef CN1_USE_ARC
2523+
[cn1StatusBarTapProxy release];
2524+
#endif
2525+
cn1StatusBarTapProxy = nil;
2526+
24892527
#ifndef CN1_USE_ARC
24902528
[super dealloc];
24912529
#endif

0 commit comments

Comments
 (0)