如何杀死TBannerAd?

时间:2017-09-18 08:06:50

标签: android delphi firemonkey

情况(德尔福柏林10.1): 在我的应用程序中,主窗体调用辅助窗体。然后,辅助表格显示Admob的横幅。即使我关闭辅助表单并清除内存,问题仍然存在,横幅继续显示。如何完全隐藏横幅?提前谢谢。

以下是辅助单位的​​代码:

unit ad_Unit;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes,
  System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
  FMX.Advertising, FMX.Controls.Presentation, FMX.StdCtrls;

type
  TAdForm = class(TForm)
    OKButton: TButton;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    FBannerAd: TBannerAd;
  public
  end;

var
  AdForm: TAdForm;

implementation

{$R *.fmx}

procedure TAdForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if Assigned(FBannerAd) then
  begin
    FBannerAd.Hide;
    FBannerAd.DisposeOf;
    FBannerAd := nil;
  end;
  Action := TCloseAction.caFree;
end;

procedure TAdForm.FormCreate(Sender: TObject);
begin
  FBannerAd := TBannerAd.Create(Self);
  FBannerAd.Parent := Self;
  FBannerAd.AdUnitID := '<ID>';
  FBannerAd.Align := TAlignLayout.Top;
  FBannerAd.TestMode := True;
end;

procedure TAdForm.FormShow(Sender: TObject);
begin
  FBannerAd.LoadAd;
end;

end.

0 个答案:

没有答案