【发布时间】:2011-12-09 16:36:32
【问题描述】:
我为 mac 制作了一个简单的应用程序,但是当它加载内容(通过 JS)时,由于添加或其他原因,它会重定向,有没有办法阻止 WebView 转到任何其他 URL,而不是在代码?
目前正试图通过 (UPDATED) 来阻止它
webberAppDelegate.h
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
@interface webberAppDelegate : NSObject <NSApplicationDelegate> {
WebView *webview;
}
@property (assign)IBOutlet WebView *webview;
@end
webberAppDelegate.m
#import "webberAppDelegate.h"
@implementation webberAppDelegate
//@synthesize window;
//@synthesize webber;
@synthesize webview;
- (void)applicationDidFinishLaunching:(NSNotification *)Notification
{
NSURL*url=[NSURL URLWithString:@"http://simplyshows.com/dev/forums/"];
NSURLRequest*request=[NSURLRequest requestWithURL:url];
[[webview mainFrame] loadRequest:request];
webview.resourceLoadDelegate = self;
}
-(NSURLRequest*) webView:(WebView*)webview resource:(id)sender willSendRequest:(NSURLRequest*)request redirectResponse:(NSURLResponse*)redirectresponse fromDataSource:(WebDataSource*)dataSource {
NSLog(@"willSendRequest delegate method called");
}
@end
【问题讨论】:
标签: objective-c xcode macos uiwebview