Using the canvas drawImage() function on Iphone web apps
I am working on a web app for the Iphone. I have a web page using a canvas on which I draw lines, arks, circles, and some images using the canvas drawImage() function. the page loads and runs fine in windows chrome, windows safari, OSX chrome, and OSX safari but not iphone safari.
It seems to stop at the drawImage() function. I've searched for information on the whether or not the Iphone supports the canvas drawImage 开发者_StackOverflow中文版function but can't find anything. What have I missed?
The problem is probably that the image hasn't loaded yet when you make the draw call. Don't worry, this has happened to me too. What you need to do is:
var image = new Image( "http://mydomain/myimage.jpg" );
image.onload = function() {
context.drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh);
}
精彩评论