Skip to content

Commit 4d6068a

Browse files
Grace Guaafrooze
authored andcommitted
Lp 10193 rich interstitial fullscreen (#300)
* adjust insets for iphoneX landscape * fix main frame size * with fix * uncomment * add code * format * more formatting * last format change
1 parent e461dc0 commit 4d6068a

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

Leanplum-SDK/Classes/LPMessageTemplates.m

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -969,17 +969,18 @@ - (void)updatePopupLayout
969969
orientationTransform = CGAffineTransformIdentity;
970970
}
971971
_popupGroup.transform = orientationTransform;
972+
972973
CGSize screenSize = window.screen.bounds.size;
973974
_popupGroup.frame = CGRectMake(0, 0, screenSize.width, screenSize.height);
974975

975976
CGFloat screenWidth = screenSize.width;
976977
CGFloat screenHeight = screenSize.height;
978+
977979
if (orientation == UIDeviceOrientationLandscapeLeft ||
978980
orientation == UIDeviceOrientationLandscapeRight) {
979981
screenWidth = screenSize.height;
980982
screenHeight = screenSize.width;
981983
}
982-
983984
_popupView.frame = CGRectMake(0, 0, screenWidth, screenHeight);
984985
if (!fullscreen) {
985986
_popupView.frame = CGRectMake(0, 0, [[context numberNamed:LPMT_ARG_LAYOUT_WIDTH] doubleValue],
@@ -1005,7 +1006,7 @@ - (void)updatePopupLayout
10051006
dismissButtonX = _popupView.frame.origin.x + _popupView.frame.size.width - 3 * _dismissButton.frame.size.width / 4;
10061007
dismissButtonY = _popupView.frame.origin.y - _dismissButton.frame.size.height / 4;
10071008
}
1008-
1009+
10091010
_dismissButton.frame = CGRectMake(dismissButtonX - leftSafeAreaX, dismissButtonY, _dismissButton.frame.size.width,
10101011
_dismissButton.frame.size.height);
10111012
}
@@ -1068,13 +1069,20 @@ - (void)updateHtmlLayoutWithContext:(LPActionContext *)context
10681069
_popupGroup.frame = CGRectMake(htmlX, htmlY, htmlWidth, htmlHeight);
10691070

10701071
} else if (isIPhoneX) {
1072+
UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
1073+
if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
1074+
safeAreaInsets.left = 0;
1075+
safeAreaInsets.right = 0;
1076+
bottomSafeAreaHeight = 0;
1077+
}
1078+
10711079
_popupGroup.frame = CGRectMake(safeAreaInsets.left, safeAreaInsets.top,
10721080
screenWidth - safeAreaInsets.left - safeAreaInsets.right,
10731081
screenHeight - safeAreaInsets.top - bottomSafeAreaHeight);
10741082

1075-
NSLog( @"%@", NSStringFromCGRect(_popupGroup.frame) );
1076-
NSLog(@"%f, %f", screenWidth, screenHeight);
1077-
NSLog(@"%@", NSStringFromUIEdgeInsets(safeAreaInsets));
1083+
NSLog(@"frame dim %@ %@", NSStringFromCGRect(_popupGroup.frame), NSStringFromCGSize(_popupGroup.frame.size));
1084+
NSLog(@"screen %f, %f", screenWidth, screenHeight);
1085+
NSLog(@"insets %@", NSStringFromUIEdgeInsets(safeAreaInsets));
10781086
}
10791087

10801088
_popupView.frame = _popupGroup.bounds;
@@ -1192,6 +1200,9 @@ - (void)refreshPopupContent
11921200
UIWebView *webView = (UIWebView *)_popupView;
11931201
_webViewNeedsFade = YES;
11941202
webView.delegate = self;
1203+
if (@available(iOS 11.0, *)) {
1204+
webView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
1205+
}
11951206
if ([actionName isEqualToString:LPMT_WEB_INTERSTITIAL_NAME]) {
11961207
[webView loadRequest:[NSURLRequest requestWithURL:
11971208
[NSURL URLWithString:[context stringNamed:LPMT_ARG_URL]]]];

0 commit comments

Comments
 (0)