开发者

how to use webkit in my iphone application to link javascript

开发者 https://www.devze.com 2023-01-28 10:28 出处:网络
How do i use webkit in my application to link javascript? My purpose is to call javascript function from my objective C code. I am reading that I need to have webkit embedded in my application to be

How do i use webkit in my application to link javascript?

My purpose is to call javascript function from my objective C code. I am reading that I need to have webkit embedded in my application to be able to do so. However I am unsure on how to use it from my applic开发者_运维百科ation?


UIWebView has an instance method that handles this:

stringByEvaluatingJavaScriptFromString:


Something like this might help

WebView* wview = [[WebView alloc] initWithFrame: NSMakeRect( 0.0,
    0.0, 1.0, 1.0 ) frameName: @"frame" groupName: @"group" ];

WebScriptObject* wso = [wview windowScriptObject ];
[wso evaluateWebScript: @"{YOUR SCRIPT CODE}"];
NSObject* proxyDefinition = [ wso callWebScriptMethod:
    @"YourMethod" withArguments: [ NSArray arrayWithObjects: "testarg",nil]];
0

精彩评论

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