lqdsj
lqdsj
  • 发布:2015-05-19 17:43
  • 更新:2015-05-20 12:56
  • 阅读:2579

ios 在 index.html 页面中调用模板加载方法, 然后Object-c 的回调就不起作用了

分类:5+ SDK
iOS

在 index.html 页面中调用了这个方法, 然后回调就不起作用了(注释掉tinit方法,有正确返回), 代码如下:
<script type="text/javascript" charset="utf-8">
mui.init({
swipeBack: false
});
tinit();
document.addEventListener("plusready", function(){
domindPlugin.checkTester();
});
</script>

domindPlugin.checkTester();方法请参考:
http://ask.dcloud.net.cn/question/5509?notification_id-24924rf-falseitem_id-9085__answer_id-9085__single-TRUE#!answer_9085

//以下为js中的代码
function initTemplates() {
getTemplate('default', '../templates/template.html');
};

//初始化模板
function tinit(){
mui.plusReady(function() {
//关闭splash页面;
plus.navigator.closeSplashscreen();
//初始化模板
//延迟加载的原因:等待index页面先创建menu和mask,这样就可以保证页面的zindex顺序;
setTimeout(function() {
initTemplates(); //预加载所有模板
}, 300);
});
}

var templates = {};
function getTemplate(name, header, content, loading) {
var template = templates[name];
if (!template) {
//alert('template');
//预加载共用父模板;
var headerWebview = mui.preload({
url: header,
id: name + "-main",
styles: {
popGesture: "hide",
zindex: 2
},
extras: {
mType: 'main'
}
});
//预加载共用子webview
var subWebview = mui.preload({
url: !content ? "" : content,
id: name + "-sub",
styles: {
top: '72px',
bottom: '0px',
zindex: 2
},
extras: {
mType: 'sub'
}
});
//loaded 页面加载完成后显示
subWebview.addEventListener('loaded', function() {
setTimeout(function() {
subWebview.show();
}, 50);
});
subWebview.hide();
headerWebview.append(subWebview);
//iOS平台支持侧滑关闭,父窗体侧滑隐藏后,同时需要隐藏子窗体;
if (mui.os.ios) { //5+父窗体隐藏,子窗体还可以看到?不符合逻辑吧?
headerWebview.addEventListener('hide', function() {
subWebview.hide("none");
});
}
templates[name] = template = {
name: name,
header: headerWebview,
content: subWebview,
loaded: loading
};
}
return template;
};

2015-05-19 17:43 负责人:无 分享
已邀请:
wey

wey

官方有人回复吗?我也遇到这个问题了。

DCloud_IOS_XTY

DCloud_IOS_XTY

请在群里直接找我

  • lou

    我好像也是这个问题。。。模板加载,之后oc就不回调了

    2015-09-25 16:33

该问题目前已经被锁定, 无法添加新回复