yxinlai
yxinlai
  • 发布:2018-01-02 22:35
  • 更新:2018-01-02 22:35
  • 阅读:1133

view append 到 webview ,IOS下不正常。

分类:MUI

(function(tab) {
var COLOR_BACKGROUND = "#efeff4";
var COLOR_DEFAULT = "#000000";
var COLOR_ACTIVE = "#007AFF";
var COLOR_BORDER = "#E3E3E3";
var TAB_HEIGHT = 44;
var tabObj = null;
tab.create = function(args) {
if(!args || args.items.length == 0) {
return;
}

                tabObj = new plus.nativeObj.View('tabObj', {  
                    top: '0px',  
                    left: '0px',  
                    height: TAB_HEIGHT + 'px',  
                    width: '100%',  
                    backgroundColor: COLOR_BACKGROUND  
                });  

                function drawTitle() {  
                    var widthStep = parseInt(1 / args.items.length * 100) + 1;  
                    var titleWidth = (window.innerWidth * widthStep / 100).toFixed(2);  
                    var tabTitles = [];  
                    for(var i = 0, j = args.items.length; i < j; i++) {  
                        var item = args.items[i];  
                        item.left = titleWidth * i;  
                        item.right = titleWidth * (i + 1);  

                        var text = {  
                            tag: 'font',  
                            id: 'font' + i,  
                            text: item.title,  
                            textStyles: {  
                                size: '15px'  
                            },  
                            position: {  
                                top: '0px',  
                                left: i * widthStep + '%',  
                                width: widthStep + '%',  
                                height: '100%'  
                            }  
                        }  
                        var border = {  
                            tag: 'rect',  
                            id: 'rect' + i,  
                            position: {  
                                top: (TAB_HEIGHT - 1) + 'px',  
                                left: i * widthStep + '%',  
                                width: widthStep + '%',  
                                height: '1px'  
                            }  
                        };  

                        if(item.active) {  
                            text.textStyles.weight = 'bold';  
                            text.textStyles.color = COLOR_ACTIVE;  
                            border.position.top = (TAB_HEIGHT - 2) + 'px';  
                            border.position.height = '2px';  
                            border.color = COLOR_ACTIVE;  
                        } else {  
                            text.textStyles.color = COLOR_DEFAULT;  
                            border.color = COLOR_ACTIVE;  
                            border.color = COLOR_BORDER;  
                        }  

                        tabTitles.push(text);  
                        tabTitles.push(border);  

                    }  
                    tabObj.draw(tabTitles)  
                };  

                tabObj.setTouchEventRect({  
                    top: "0px",  
                    left: "0px",  
                    width: "100%",  
                    height: "100%"  
                });  
                tabObj.interceptTouchEvent(true);  
                tabObj.addEventListener("click", function(e) {  
                    var touchX = e.clientX;  
                    args.items.forEach(function(item) {  
                        if(touchX > item.left && touchX < item.right) {  
                            item.active = true;  
                            item.click();  
                        } else {  
                            item.active = false;  
                        }  
                    });  

                    drawTitle();  
                }, false);  
                drawTitle();  

                tabObj.show();  

                return tabObj;  
            };  

        })(window.tabCtrl = {});  

headTab = tabCtrl.create({
top: '44px',
items: [{
title: '全部',
id: 0,
active: true,
click: function() {
tabStatus = 'all';
vm.msgList = page.datas;
mui('.mui-slider-right').each(function() {
mui.swipeoutClose(this.parentElement);
})
}
},
{
title: '未读',
id: 1,
click: function() {
tabStatus = 'unread';
vm.msgList = page.datas.filter(function(ele) {
return !ele.read;
});
mui('.mui-slider-right').each(function() {
mui.swipeoutClose(this.parentElement);
})
}
}
]
});

plus.webview.currentWebview().append(headTab);

上面这段代码在一个预加载页面内,安卓下运行正常;在IOS下,view直接显示,不是隶属预加载页面。
求大神解救

2018-01-02 22:35 负责人:无 分享
已邀请:

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