【问题标题】:Is it possible to load a webview into a NSMenuItem in OS X?是否可以将 webview 加载到 OS X 中的 NSMenuItem 中?
【发布时间】:2014-07-29 04:18:40
【问题描述】:

当我尝试这段代码时,我得到了错误: Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_WebView", referenced from: objc-class-ref in AppController.o

webview=[[WebView alloc]initWithFrame:CGRectMake(0, 0, 100,30)];
NSString *url=@"http://www.google.com";
NSURL *nsurl=[NSURL URLWithString:url];
NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
[webview.mainFrame  loadRequest:nsrequest];
[self.webViewMenuItem setView:webview];

webViewMenuItem 是一个通过 IBOutlet 链接的 NSMenuItem。

【问题讨论】:

  • 不确定,但是你是否包含了 webkit 框架?
  • 是的,包括 webkit。我发现有些人认为它应该有效,但没有成功的证据!
  • 啊,我有它,但忘记在应用程序设置中链接框架!错误已经消失,但它没有加载页面..感谢指针
  • 我不知道为什么 NSMenuItem 上没有 webview 的证据。有任何想法吗?谢谢!
  • 我现在不在电脑附近.. 但是你能设置网络加载代理,看看它是否被加载了吗?由于谷歌有很多空白空间,它可能不适合框架

标签: objective-c macos cocoa nsmenuitem


【解决方案1】:

好的,为了完成这个问题:

架构 x86_64 的未定义符号:“_OBJC_CLASS_$_WebView”, 引用自:AppController.o中的objc-class-ref

那是因为项目中没有添加 Webkit 框架。

是否可以在 OS X 中将 webview 加载到 NSMenuItem 中

是的,这是可能的,但请确保在父视图完全加载完成后加载 webview。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-10-21
    • 2015-12-07
    • 2015-04-26
    • 2021-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-13
    相关资源
    最近更新 更多