美文网首页
iOS WebView 设置回调函数

iOS WebView 设置回调函数

作者: 曾令伟 | 来源:发表于2016-08-31 15:24 被阅读237次

    #ifdef __cplusplus

    extern"C"{

    #endif

    #include"tolua++.h"

    #ifdef __cplusplus

    }

    #endif

    #include"cocos-ext.h"

    usingnamespace::std;

    usingnamespace::cocos2d;

    usingnamespace::extension;

    intlua_game_Text_openWap(lua_State* tolua_S)

    {

    #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)

    size_tlen;

    constchar* url =lua_tolstring(tolua_S,1, &len);

    intscale =lua_tonumber( tolua_S,2);

    constchar* scheme =lua_tostring(tolua_S,3);

    floatf = scale *0.1;

    experimental::ui::WebView* pbView =experimental::ui::WebView::create();

    pbView->setPosition(ccp(640,360));

    autowinSize =Director::getInstance()->getWinSize();

    pbView->setContentSize(winSize * f);

    pbView->loadURL(url);

    pbView->setScalesPageToFit(true);

    pbView->setOnJSCallback(webViewCallback);  //设置url回调函数

    pbView->setJavascriptInterfaceScheme(scheme);//设置返回url的头  

    Director::getInstance()->getRunningScene()->addChild(pbView,90000,90000);

    #endif

    return1;

    }

    #include"UIWebView.h"

    相关文章

      网友评论

          本文标题:iOS WebView 设置回调函数

          本文链接:https://www.haomeiwen.com/subject/twbqettx.html