在前瞻课程中找不到属性“框架”

时间:2014-02-24 16:08:58

标签: objective-c cocoa

第一:我对可可开发很新。我想我的问题非常明显。

加载后我需要知道WebView的大小。为此,我已经找到了answer,但我遇到了问题。这是我的代码的相关部分。

App代表:

    @implementation MDAppDelegate

    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

      //set ourselves as the frame load delegate so we know when the window loads
      [self.webView setFrameLoadDelegate:self];

      // set the request variable, which works and then load the content into the webView
      [self.webView.mainFrame loadRequest:request];

    }

    - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)webFrame
    {
      NSLog(@"webView:didFinishLoadForFrame");
      if([webFrame isEqual:[self.webView mainFrame]]) {
        // some code ...
        // and at some point I want to get the frame property of self.window
        NSRect windowFrame = self.window.frame;
      }
    }

window属性在app delegate的头文件中定义:

    @interface MDAppDelegate : NSObject <NSApplicationDelegate>
      @property (weak) IBOutlet MDTransparentWindow *window;
      @property (weak) IBOutlet WebView *webView;
    @end

我找到答案(看起来似乎是)very similar problem。解决方案是#import <QuartzCore/QuartzCore.h>,并在Build Phases选项卡中链接框架。我这样做了,但问题仍然存在。我也清理了我的项目(截至目前我仍然不知道清洁做了什么,但有时它有帮助)没有结果。

该窗口是我自己的类TransparentWindow的一个实例,它是子类NSWindow的子类。当我开始在子类实现文件中编写self.f时,xcode会自动建议frame。但是,当我在self.window.f方法中编写webView:didFinishLoadForFrame时,就不会发生这种情况。

正如我所说,我是可可开发的新手。任何提示,我可能错过了什么?

1 个答案:

答案 0 :(得分:2)

如果你只做了类的前向声明,通常会收到此消息,例如

@class MyPhantasticClass;

编译器知道它是一个类,但不知道它的任何方法。您需要包含正确的头文件。