在Cocoa中,使用webview,如何在鼠标结束时在状态栏中显示链接?

Blu*_*lue 5 cocoa objective-c mouseover webview

正如标题所说,我正在使用webview来显示网站,当鼠标悬停在超文本上时我需要在状态栏中显示链接...我该怎么做?我相信这是非常容易的事情,但到目前为止我找不到任何关于此事的内容......感谢任何帮助,Massy

Blu*_*lue 6

我知道了!我很确定它太容易了...这就是我为那些遇到同样问题的人所做的事情:

-(void)webView:(WebView *)sender mouseDidMoveOverElement:(NSDictionary *)elementInformation modifierFlags:(unsigned int)modifierFlags
{    
   NSArray* keys = [elementInformation objectForKey:WebElementLinkURLKey];

   //here I pass the link to a label
   if (keys != nil) [statusBarLabel setStringValue:[NSString stringWithFormat:@"%@",keys]];
   else [statusBarLabel setStringValue:@""];

//  NSLog(@"%@",keys);
}
Run Code Online (Sandbox Code Playgroud)

另外不要忘记UIDelegate你的webView.和平,马西