仅在纵向模式下显示AdControl [英] Showing AdControl only while in Portrait mode

查看:108
本文介绍了仅在纵向模式下显示AdControl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当手机处于横向模式时,我的应用程序中的屏幕空间不足,无法显示AdControl.我在OnOrientationChanged事件处理程序中使用以下(简化)代码,以在进入横向"模式时从网格的第1行中删除AdControl,并在进入纵向"模式时将其添加回去:

There isn't enough screen real estate in my application to display an AdControl when the phone is in landscape mode. I am using the following (simplified) code in my OnOrientationChanged event handler to remove the AdControl from row 1 of the Grid when Landscape mode is entered and to add it back when Portrait mode is entered:

if (this.Orientation == PageOrientation.LandscapeLeft || 
    this.Orientation == PageOrientation.LandscapeRight) {
    LayoutRoot.Children.Remove(myAdControl);
    LayoutRoot.RowDefinitions.RemoveAt(1);// remove row to make space
} else {
    LayoutRoot.RowDefinitions.Add(adRow);// previously constructed 80 px high RowDefinition
    LayoutRoot.Children.Add(myAdControl);
    Grid.SetRow(myAdControl, 1);
}

这似乎在我的测试中有效,但是我在

This seems to work in my testing, but I saw in the documentation for the AdControl class that "Once set, the parent of an AdControl should not be changed." Is what I am doing here going to break the AdControl?

推荐答案

Here is a new solution that allows the ad control to remain stationary when the phone Orientation changes to Landscape. It uses a new control that keeps the ad control at the "bottom" even when rotated (left or right when in landscape).

10秒的概述是创建网格布局并将AdControl移至适用于方向的行/列组合.

The 10 second overview is to create a Grid layout and move the AdControl to the Row/Column combo that works for the orientation. The blog has all the detail in it.

这篇关于仅在纵向模式下显示AdControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆