我的应用委托类中的代码:
- (void)webView:(WebView *)webView decidePolicyForNewWindowAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request newFrameName:(NSString *)frameName decisionListener:(id < WebPolicyDecisionListener >)listener{
NSLog(@"hello");
NSTabViewItem *newItem=[[NSTabViewItem alloc] init];
NSInteger index = [_tabView numberOfTabViewItems];
[_tabView insertTabViewItem:newItem atIndex:index];
[newItem setLabel:@"Empty Tab" ];
//[_tabView selectPreviousTabViewItem:@"select"];
newVC =[[newViewController alloc] initWithNibName:@"newViewController" bundle:nil];
[[_tabView .tabViewItems objectAtIndex:index] setView:[newVC view]];
newViewController *obj=[newViewController alloc]init];
[obj.newWebView mainframe]loadrequest:request];
}
此代码未使用请求的 url 加载 Web 视图。这里 newWebView 是我在 newViewController 类中创建的 Web 视图属性。