开发者

ios 4.2 uiwebview javascript window.print doesn´t print, not launch before and after events

I´m using a uiwebview for doing an embedded web app, with the new iOS 4.2 you can print directly with objective-C, but I want to print from javascript in HTML.

The problem is that I dont see the print dialog showing when clicking the button that executes window.print().

I have wrote also this code but it doesn't get events.

function beforePrint () {
    alert("before rec");
}

function afterPrint () {
    alert("after rec");
}


function checks(){
    alert("Activating checks");
    window.onbeforeprint = beforePrint;
    window.onafterprint = afterPrint;
}

and this event launched from a button img

onClick="js:checks();alert('print');window.print();alert('print done');"

In a Safari I only get the messages for activating checks, the preview printing and "print", "print done" messages... also I do开发者_Go百科nt get the events.


As far as I can tell, window.print() does nothing when running the code in a UIWebView. You need to write some native Objective-C to run UIViewPrintFormatter against your UIWebView, or send the user to Safari.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜