抖音开放平台Logo
开发者文档
“/”唤起搜索
控制台
  • JavaScript API
  • API 概览
  • 基础
  • 界面
  • 渲染
  • 数据缓存
  • 文件
  • 位置
  • 设备
  • 网络
  • 媒体
  • Worker
  • 数据分析
  • 支付
  • 广告
  • tt.createGridGamePanel
  • tt.createRewardedVideoAd
  • tt.createBannerAd
  • tt.createInterstitialAd
  • BannerAd
  • BannerAd
  • BannerAd.hide
  • BannerAd.show
  • BannerAd.onLoad
  • BannerAd.offLoad
  • BannerAd.onError
  • BannerAd.offError
  • BannerAd.onResize
  • BannerAd.offResize
  • BannerAd.destroy
  • RewardedVideoAd
  • InterstitialAd
  • GridGamePanel
  • 开放能力
  • C# API
  • BannerAd.offResize
    收藏
    我的收藏

    基础库 1.3.0 开始支持本方法,这是一个同步方法。

    解除绑定 resize 事件的监听器。

    前提条件无
    业务背景无
    使用限制无
    注意事项无
    相关教程无

    语法

    BannerAd.offResize(callback)

    参数说明

    callback

    类型默认值必填说明最低支持版本
    function是

    通过 BannerAd.onResize 绑定的监听器

    1.3.0

    返回值

    无

    错误码

    errNoerrMsg说明最低支持版本
    20000internal error
    小游戏框架内部错误,有需要请创建工单咨询
    1.3.0
    20001invalid param
    1.3.0

    代码示例

    const { windowWidth, windowHeight } = tt.getSystemInfoSync(); const targetBannerAdWidth = 200; // 创建一个居于屏幕底部正中的广告 let bannerAd = tt.createBannerAd({ adUnitId: "YOUR_AD_UNIT_ID", style: { width: targetBannerAdWidth, top: windowHeight - (targetBannerAdWidth / 16) * 9, // 根据系统约定尺寸计算出广告高度 }, }); // 也可以手动修改属性以调整广告尺寸 bannerAd.style.left = (windowWidth - targetBannerAdWidth) / 2; function resize(size) { console.log(size.width, size.height); bannerAd.style.top = windowHeight - size.height; bannerAd.style.left = (windowWidth - size.width) / 2; } bannerAd.onResize(resize); bannerAd.offResize(resize);