self.webView.policyDelegate = self;
と以下のコードでSafari起動できる。
- (void)webView:(WebView *)aWebView decidePolicyForNewWindowAction:(NSDictionary *)actionInformation request:(NSURLRequest *)aRequest newFrameName:(NSString *)aFrameName decisionListener:(id < WebPolicyDecisionListener >)aListener { int navigationType = [[actionInformation objectForKey:WebActionNavigationTypeKey] integerValue]; if(navigationType == WebNavigationTypeLinkClicked) { NSDictionary *element = [actionInformation objectForKey:WebActionElementKey]; NSURL *linkURL = [element objectForKey:WebElementLinkURLKey]; [[NSWorkspace sharedWorkspace] openURL:linkURL]; [aListener ignore]; } [aListener use]; }
↑のメソッドとよく似たメソッドに↓があるけど、こっちはリンクをクリックした時には呼ばれない。これに気付かずはまった。。
- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id < WebPolicyDecisionListener >)listener