调整应用程序的画布大小 [英] Resizing canvas for the app

查看:166
本文介绍了调整应用程序的画布大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们一直在努力为canvas应用程序设置高度,而不用运气。

we have been trying to setup the height for a canvas app without luck.

这是我们使用的代码

window.fbAsyncInit = function()
{
// assume we are already logged in
FB.init({appId: '<?=$fb_app_id ?>', xfbml: true, oauth : true,cookie: true});
FB.Canvas.setAutoGrow();
}
function sizeChangeCallback() {
FB.Canvas.setSize({ width: 810, height: 950);
}

我们尝试过没有sizechangecallback

We tried both without the sizechangecallback

,我们的设置设置为固定和固定950

and our settings set to Fixed and Fixed 950

推荐答案

在应用程序设置中设置固定高度参数后,

您可以调用 FB.Canvas.setSize 来更改页面高度。

After you setup the fixed height parameter in your application settings,
you can call FB.Canvas.setSize to change the page height.

如果您的页面高度动态变化,则可以运行 FB.Canvas.setDoneLoading

来检查Canvas是否已加载并运行 FB .Canvas.setAutoGrow

If your page height changes dynamically, you can run FB.Canvas.setDoneLoading
to check if Canvas is loaded and run FB.Canvas.setAutoGrow.

window.fbAsyncInit = function() {
    // assume we are already logged in
    FB.init({ appId: '<?=$fb_app_id ?>', xfbml: true, oauth: true, cookie: true });

    FB.Canvas.setSize({ width: 810, height: 950 });

    FB.Canvas.setDoneLoading( function(response) {
        console.log(response.time_delta_ms);
        FB.Canvas.setAutoGrow();
    });
}

FB文档: https://developers.facebook.com/docs/reference/javascript/FB.Canvas.setDoneLoading/

这篇关于调整应用程序的画布大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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