2012-02-02 125 views

回答

3

在你的HTML中,給URL一個特殊的方案。在這個例子中,該計劃是perform

<!-- ontouchstart tells WebKit to send us mouse events on a touch platform so we can use :active --> 
<button class="button" ontouchstart="" onclick="window.open('perform:MAX')">MAX</button> 

(你可以在這裏使用<a href或其他技術這個例子使用onclick很有用來自碼。)

設置你的控制器的委託UIWebView。然後執行這個委託方法:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request 
               navigationType:(UIWebViewNavigationType)navigationType 
{ 
    NSURL *url = request.URL; 
    if ([[url scheme] isEqualToString:@"perform"]) 
    { 
    // url.resourceSpecifier will be @"MAX" in this example 
    // Do something with it. 
    return NO; 
    } 

    return YES; 
} 
+0

COOL!非常感謝! – uriel 2012-02-02 16:23:14