How to detect SmartBanner - ios

A smartbanner is apple's direct link to the app store. https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/PromotingAppswithAppBanners/PromotingAppswithAppBanners.html
I am trying to have the smart banner show on the top of the page, content below it, and the nav bar on the bottom. The issue I run into is the smart banner is not counted as part of screen height. If you were to do either:
height: 100%;
screen.innerHeight;
height: 100vh;
or any other typical request for screen height, it ignores the presence of the smart banner and pushes content offscreen by the delta of the smart banner's height.
I am trying to detect if the smart banner is showing on an iOS device to ensure the page fits the window screen regardless of its presence and updates height accordingly. What I've found is that the smart banner shows after the document is ready, and doesn't affect window height. Is there a simple way to detect if the user is being shown the smart banner?
$(document).ready(function() {
heightResize($(".container"));
$(window).resize(function() {
heightResize($(".container"));
$(".container").append("<div class='banner'>this is your dynamically created banner</div>");
$(".container").height($(".container").height()+$(".banner").height());
});
});
function heightResize(element) {
element.height($(window).height()-20);
$("p").text(element.height());
}
Code like this will be pushed off the screen by the smart banner after the page finishes loading.

Related

Swift / React Native How to know split view / slide over app's position relative to the whole screen?

I'm making a react-native based app, and I can partially use Swift code by react-native's NativeModule feature.
My app will be used as Split view / Slide over mode in iPad, and I want to know if my app is in the left-side, right-side, or Slide-over.
I could get width and height, also origin (CGPoint) by this code.
let window = UIApplication.shared.windows.first
// Then getting X, Y like this...
window.frame.origin.x
Now my app has only one webview, made by react-native-webview.
So I guess, since the webview is the whole content of the app, and it fills app 100%, so it always returns app.
I want to know, not in webView's perspective, but in app's perpective, the POSITION relative to the screen.
For example, if my iPad width is 1400, and if my app is on the half right side, x should be 700.
And if it is on left side, it should be 0.
I really struggled this, but couldn't find any solution.
FYI, I drawed a diagram for this question.
As I wrote on the above, I tried UIApplication.shared.windows.first.frame.
But it only show the CGPoint of webview, not app relative to the screen.
There is no API for getting 'X' or 'LEFT' in react-native-dimension too.
onLayout also not helpful.

React Native Gesture Reponder inside hybrid app

I'm trying to use the touch event position when clicking a image to start animating a image from that location and to the center of the screen.
When react native is taking the full screen this is not a issue. But when React Native is running in a hybrid app and the screen that is rendered by React Native is not taking up the whole screen (like in a split view mode, or in a popup view on iPad) the nativeEventcoordinates are all relative to the view where React Native is rendering, and not the actual screen.
I would like to get the actual screen coordinates where the touch is happening. Is there any workaround to make this happen?
From the documentation of the Gesture Responder System all the events are relative to the root element. And I assume this means the root element of react native.
I did some experimenting and the react native Dimensions do give me the correct screen size. I was first thinking of using that to calculate the offset of where the React Native screen is being rendered. But I can't really know how much spacing is at the top/bottom/left/right of the view with just this data.
Figured it out.
I can use measureInWindow to figure out the actual screen coordinates when React Native is running in a subview of a hybrid app.
onPress = () => {
this.refs.button.measureInWindow((x, y, width, height) => {
console.log("x", x, "y", y);
})
}
render() {
<TouchableOpacity ref="button" onPress={this.onPress}>
...
</TouchableOpacity>
}

How to get rid of the status bar background on the UIWebView?

Since iOS 11, when the UIWebView is full screen, a fake background appears on the status bar with the same color of the UIWebView background.
Anyone knows how to get rid of it?
Even adding the IUWebView to a storyboard and make it full screen will make the status bar background to appear
I've been trying to edit the size and some other properties of the UIWebView and none of them worked, but it's definitely something from the UIWebView.
Also tried to see all the subviews and it's sizes and didn't see anything strange.
Attached a screenshot, see the grey "statusbar", it disappears when scrolling, and doesn't appear if the UIWebView is not over that part of the screen.
I want it as on the second screenshot, only remove the fake background, not the status bar.
This happens because of UIScrollView new behavior to adjust the content inset to include safe area insets like the status bar.
To fix it, just set it to UIScrollViewContentInsetAdjustmentNever
[self.webView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
Since iOS 11 Beta 4 you can add this to your viewport and will also remove the fake statusbar
viewport-fit=cover
To do this entirely in HTML/CSS, viewport-fit=cover in the Viewport meta tag is the correct way to handle this.
But you'll also want to adjust your padding dynamically to handle the differently sized status bar on iPhone X with its notched camera/speaker.
Luckily, Apple exposed some CSS constants for the safe area insets, so you can take advantage of those in your CSS:
i.e., padding-top: constant(safe-area-inset-top);
I wrote a bit more about this scenario and the new features for iOS 11 and iPhone X: https://ayogo.com/blog/ios11-viewport/
Swift version:
webView.scrollView.contentInsetAdjustmentBehavior = .never

How to design an iPhone app that uses both Portrait and Landscape in Flash CS6

So I have created an App that has a different menu when it is held portrait, but changes when held landscape.
I can get the navigation to work, However I am unsure how to design landscape pages inside Flash?
My stage is set to the standard 640x960 air for iOS, which gives me perfect portrait pages, But when I tilt my phone to landscape the screen obviously changes, and it looks weird. Im hoping someone can tell me how i can get this view inside Flash, while still having the portrait screens too?
I want to have both Portrait and Landscape in the same app, and am currently so confused how I can design this inside flash?
I hope this makes sense, and that someone could throw some help my way!
It's not easy, but you can do it. First, you have to wait until stage is initialized and set it's scaling property to no scale (this will stop resizing page to fill screen). Then you have to listen to stage's resizing (it trigger's every time you rotate iPhone) and to move/scale your display objects in proper way in the listener handler.
addEventListener(Event.ADDED_TO_STAGE, init); //Wait for stage initialization
private function init(e:Event):void { //init handler
removeEventListener(Event.ADDED_TO_STAGE, init); //remove listener, which won't be used more
stage.scaleMode = StageScaleMode.NO_SCALE; //set null scaling and top-left align
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, resize); //add handler for resizing
}
private function resize(e:Event):void { //triggers every time iPhone being rotated
//Move/scale your objects here
}

How to display iAd Banner with UIModalPresentationFormSheet

Any possibility of displaying an iAd banner in a UIModalPresentationFormSheet?
Reading the documentation there are is no size listed for iPad form sheet:
https://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/iAd_Guide/BannerAdvertisements/BannerAdvertisements.html
It also says "In the future, additional sizes may be exposed by iAd."
In the meantime, any recommendations on how to handle this? The form view on iPad will display for a long period of time and is where the ad banner should be.
Searching a bit, I see there's some code to display ads from other network types, in this case "ad mob", in a form view:
https://github.com/navisingh/ad-networks/tree/master/GoogleAdMobAdsSDK
If iAd does not support form sheet, then I guess I could search other networks.
UPDATE: Ad Mob supports sizing as follows...
// Size ad banner to form view width
CGFloat aWidth = [self view].frame.size.width;
adMobBannerView_ = [[GADBannerView alloc] initWithAdSize:GADAdSizeFromCGSize(CGSizeMake(aWidth, 60.0f))];

Resources