how to use webkit in my iphone application to link javascript
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]];
精彩评论