我试图从应用程序外部加载URL到webview。我已经设置好了我的信息。Plist正确支持http, https。我的应用程序出现在处理程序列表(safari首选项pan)。这是我的代码
我在awakefromnib中有这个
NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager];
[em
setEventHandler:self
andSelector:@selector(getUrl:withReplyEvent:)
forEventClass:kInternetEventClass
andEventID:kAEGetURL];
和
//get the URL from outside the application
- (void)getUrl:(NSAppleEventDescriptor *)event
withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
// Get the URL
NSString *urlStr = [[event paramDescriptorForKeyword:keyDirectObject]
stringValue];
[self initWithUrl:urlStr];
}
//Can be used as intializer to init the webview with a page
-(void)initWithUrl:(NSString *)url
{
//load the lading home page
[[webview mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
}
如果我nslog url,它显示它(所以它正确地得到它)。我的下一个方法也被调用。这个方法在我的应用程序中工作得很好。
问题是,当我点击我的应用程序外的链接(一旦应用程序被选择为默认浏览器)。我弹出窗口,但它没有加载URL。它什么也不做。知道吗?
webview的"mainFrame"方法是什么?那是自定义类吗?您是否将web视图的框架添加到窗口的框架中?