Re: TextView from HTML with embedded images
Re: TextView from HTML with embedded images
- Subject: Re: TextView from HTML with embedded images
- From: Scott Anguish <email@hidden>
- Date: Mon, 23 Sep 2002 16:51:25 -0400
On Monday, September 23, 2002, at 01:54 PM, David Sinclair wrote:
Thanks, that extra parameter did the trick... mostly. It doesn't load
the images when the page is first displayed, but if it is reloaded
after a little while, they appear. So it must begin loading them
after the page is displayed (or that init method is called), so
they're cached for a subsequent call.
So... my next question is: is there a notification or delegate method
to know when the images are loaded? I tried using the
-textDidChange: delegate method, and using a timer to call -display
on the text view, but neither of those worked. I could store the
attributed string from the page and reload it later... but I don't
know when the images have loaded.
Any thoughts?
Yep, there is an undocumented notification for this.
Each time your document is changed as it loads, it gets a
HTMLDocumentChangedNotification which has some useful information in the
key as far as what happened.
I wrote an article on this just after this was added (way back in
the Rhapsody days).. I'm not sure where it disappeared to.. but it
walked you though building an app in like 12 lines that could browse the
web.
The notifications are of course unofficial, and unsupported...
You can find out all sorts of cool stuff by using an app like this
#import "AppDelegate.h"
@implementation AppDelegate
- (void)awakeFromNib
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(gotNotification:) name:NULL object:NULL];
}
- (IBAction)loadURL:(id)sender
{
NSAttributedString *theStr;
NSURL *theURL = [NSURL
URLWithString:@"
http://www.stepwise.com/index.html"];
theStr=[[NSMutableAttributedString alloc] initWithHTML:[theURL
resourceDataUsingCache:NO]
baseURL:theURL
documentAttributes:NULL];
[[theText textStorage] setAttributedString:theStr];
}
- (void)gotNotification:(NSNotification *)notification
{
if ([[notification name] hasPrefix:@"HTML"]) {
NSLog(@"[notification object] %@",[notification object]);
NSLog(@"[notification name] %@",[notification name]);
NSLog(@"[notification userInfo] %@",[notification userInfo]);
}
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.