Quantcast
Channel: Cocos中文社区 - 最新主题
Viewing all articles
Browse latest Browse all 88737

Creator 手机拍照和获取相册的问题!!!大神快来

$
0
0

@531223011 写道:

用的html5来获取的相册
1,然后发布到web上用手机浏览器访问可以打开相册
2,微信扫一扫也可以打开相册
3,但是发布apk后安装到手机上的app却打不开!!!为什么呀??为什么呀??

function loadLocalimg(uri)
{
	var my = document.getElementById("divCreator");
	if(my===null)
    {
        my = document.createElement("div");   
        document.body.appendChild(my);   
        my.style.position="absolute";   
    	my.id="divCreator";
        my.style.width=100;   
        my.style.height=100;   
        my.style.backgroundColor="#ffffcc";   
	}
	my.innerHTML = '<img id=imghead>';
    var img = document.getElementById('imghead');
    img.onload = function()
    {
		var n=0;
		var spriteFrame=spImg.getComponent('cc.Sprite').spriteFrame;
		var texture=spriteFrame.getTexture();
		texture.initWithElement(this);
		texture.handleLoadedTexture();
		cc.log("width="+this.width);
		cc.log("height="+this.height);
		n++;
    }
	img.src = uri;
	my.style.display='none';
	my.style.visibility = "hidden";
}
function tmpSelectFile(evt) {
    //console.log("image selected...");
    var file = evt.target.files[0];
    var type = file.type;
    if (!type) {
        type = mime[file.name.match(/\.([^\.]+)$/i)[1]];
    }
    var url = myCreateObjectURL(file);
    loadLocalimg(url);
    
}

function myCreateObjectURL(blob){
    if(window.URL !== undefined)
        return window['URL']['createObjectURL'](blob);
    else
        return window['webkitURL']['createObjectURL'](blob);
}

帖子: 2

参与者: 1

阅读整个主题


Viewing all articles
Browse latest Browse all 88737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>