Binding to properties of WebView (Cocoa WebKit)
I'm storing font preferences for a WebView in my shared user defaults. I have a WebView set up in my XIB, but it isn't possible to bind a WebView's font properties in IB, so I'm wondering if I can do it in code instead. I've tried this:
WebPreferences *webPrefs = [WebPreferences standardPreferences];
[webPrefs bind:@"fixedFontFamily"
toObject:[NSUserDefaultsController sharedUserDefaultsController]
withKeyPath:@"values.webViewMonospaceFontFamily"
开发者_如何学Go options:nil];
[myWebView setPreferences:webPrefs];
and it doesn't work.
If this is not going to work, what would be a working strategy for changing my WebView's font when the user selects a new font in my preferences window? Do I have to manually set it in my changeFont:
method?
Update. This does work. WebPreferences has more font properties than I thought, and fixedFontFamily
was the wrong one for the page I was viewing.
精彩评论