简体   繁体   English

如何使用 Xamarin.iOS 将广告内容分配给 stacklayout

[英]How to assign ad content to stacklayout using Xamarin.iOS

I want to assign a banner content into stacklayout.我想将横幅内容分配到 stacklayout 中。 In my MainPage.xaml I create a new stacklayout with x:Name="Advertising".在我的 MainPage.xaml 中,我使用 x:Name="Advertising" 创建了一个新的堆栈布局。

<StackLayout x:Name="Advertising">

    </StackLayout>

Now I want to move the content from my banner directly into stacklayout.现在我想将横幅中的内容直接移动到 stacklayout 中。 My c# code in my MainPage.xaml.cs is:我的 MainPage.xaml.cs 中的 c# 代码是:

AdmobControl admobControl = new AdmobControl()
        {
            AdUnitId = AppConstants.BannerId
        };
        

        Content = new StackLayout()
        {
            Children = { admobControl }
        };

How can I move the content Children = { admobControl } into my new stacklayout with x:Name="Advertising"?如何使用 x:Name="Advertising" 将内容Children = { admobControl }移动到我的新堆栈布局中?

add it to the existing StackLayout将其添加到现有的StackLayout

Advertising.Children.Add(admobControl);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM