开发者

objective-c : when delegating webview, how to get webViewDidChange work?

I have the following interface

   #import <Cocoa/Cocoa.h>
   #import <WebKit/WebView.h> 
   #import <WebKit/WebFrame.h>
   #import <WebKit/WebEditingDelegate.h>
   @interface CounterController: WebView 
   {
        WebView* myWebView;
   }
   @proper开发者_StackOverflow中文版ty (assign) IBOutlet WebView *myWebView;
   @end

and this implementation

   #import "CounterController.h"
   @implementation CounterController

   -(id)init
    {
    [super init];
    [super setEditingDelegate:self];
        return self;
    }

    - (void)webViewDidChange:(NSNotification *)notification
    {
        NSLog(@"Hello World");
    }

the HTML file which is run by webview has this editable area

  <div id="bar" contenteditable="true">
  dddddd
  </div>

when I run the script it works fine and the editable content is editable; however, "hello world" is not printed in the consol so I assume that the delegate method "webViewDidChange" is not working!

am I doing the delegate right, why this method "webViewDidChange" is not working? and how to get it work?

Thanks very much


Please don't try to subclass WebView for this; create a proper separate controller object. You should find that the editing delegate works great then.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜