Re: TextView from HTML with embedded images
Re: TextView from HTML with embedded images
- Subject: Re: TextView from HTML with embedded images
- From: David Sinclair <email@hidden>
- Date: Mon, 23 Sep 2002 14:50:54 -0700
Thank you again -- that was very helpful. I now receive that
notification and call replaceCharactersInRange:withAttributedString:
again, which makes the text view display each image as it is loaded.
Perfect.
Another nicety would be to have an option not to load any images. I'm
not sure if that would be possible, though, and isn't essential.
Of course, you would have typed that code from memory, and I very much
appreciate it. But for anyone else reading this who might want to copy
and paste that code: note that it would leak in its current form. You
should add [theStr release] at the end of the loadURL: method, or
add autorelease to the alloc line.
David
On Monday, Sep 23, 2002, at 13:51 US/Pacific, Scott Anguish wrote:
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.