FTCoreText
FTCoreText copied to clipboard
(request) : be able to load remote images
Hi, It would be awesome if we can load images remotely :) ! I tried to but it did not work. Maybe you can edit my code to implement it easier in the repo ? look at this : stackoverflow.com/questions/11927942/ios-core-text-loosing-context-when-drawing-image-inside-a-block
I have do some modify to support dynamic loading remote images, but it add a depend on SDWebImage(maybe rewrite the loading progress), add it to the processText method else if (currentSupernode.isImage) { //replace active string with emptySpace NSRange elementContentRange = NSMakeRange(currentSupernode.startLocation, tagRange.location - currentSupernode.startLocation); NSString * elementContent = [processedString substringWithRange:elementContentRange];
UIImage *img = nil;
if ([elementContent hasPrefix:@"http"]) {
// image from http
// try to load from cache
img = [[SDImageCache sharedImageCache] imageFromKey:elementContent];
if (!img) {
// not in cache, load it from URL
img = [UIImage imageNamed:@"loading"];
NSURL *imgURL = [NSURL URLWithString:elementContent];
NSLog(@"loading image %@", elementContent);
// download it
id successblock = ^(UIImage *image) {
NSLog(@"loaded %@", elementContent);
currentSupernode.image = image;
currentSupernode.style.leading = image.size.height;
[self didMakeChanges];
if ([self superview]) [self setNeedsDisplay];
};
id failedblock = ^(NSError *error) {
NSLog(@"load image failed %@", elementContent);
};
[[SDWebImageManager sharedManager] downloadWithURL:imgURL
delegate:self
options:0
success:successblock
failure:failedblock];
}
}
else
{
img = [UIImage imageNamed:elementContent];
}
if (img) {
currentSupernode.image = img;
}
else {
NSLog(@"FTCoreTextView :%@ - Couldn't find image '%@' in main bundle", self, NSStringFromRange(elementContentRange));
[processedString replaceCharactersInRange:tagRange withString:@""];
}
I modified with your code, but get an error, for this line: currentSupernode.image = image; and currentSupernode.image = img; the error: Property 'image' not found on object of type 'FTCoreTextNode *'
can i remove original "else if (currentSupernode.isImage){ ....} or not?
There are specifics tags to refer to for special instances like images and unordered lists. They are listed in the header file. Fra.
Francesco Frison [email protected] +447766561587 From my iPhone
On 2 Sep 2012, at 13:41, KommyKT [email protected] wrote:
I modified with yout code, but get an error, for this line: currentSupernode.image = image; and currentSupernode.image = img; the error: Property 'image' not found on object of type 'FTCoreTextNode *'
— Reply to this email directly or view it on GitHubhttps://github.com/FuerteInternational/FTCoreText/issues/12#issuecomment-8221559.
the image property is UIImage * type which add to FTCoreTextNode class. (BTW, I have do much modification for this project, but I don't how to push my work.)
2012/9/2 KommyKT [email protected]
I modified with yout code, but get an error, for this line: currentSupernode.image = image; and currentSupernode.image = img; the error: Property 'image' not found on object of type 'FTCoreTextNode *'
— Reply to this email directly or view it on GitHubhttps://github.com/FuerteInternational/FTCoreText/issues/12#issuecomment-8221559.
Yout can send the modified code by e-mail or any filesharing portal.
On Sep 19, 2012, at 8:19 AM, dourgulf [email protected] wrote:
the image property is UIImage * type which add to FTCoreTextNode class. (BTW, I have do much modification for this project, but I don't how to push my work.)
2012/9/2 KommyKT [email protected]
I modified with yout code, but get an error, for this line: currentSupernode.image = image; and currentSupernode.image = img; the error: Property 'image' not found on object of type 'FTCoreTextNode *'
— Reply to this email directly or view it on GitHubhttps://github.com/FuerteInternational/FTCoreText/issues/12#issuecomment-8221559.
— Reply to this email directly or view it on GitHub.
Or you can do a push request on github. Francesco.
Francesco Frison Mobile: +447766561587 [UK] Mail: [email protected] Skype: ziofritz --- www.ziofritz.com ---
On 19 Sep 2012, at 11:18, KommyKT [email protected] wrote:
Yout can send the modified code by e-mail or any filesharing portal.
On Sep 19, 2012, at 8:19 AM, dourgulf [email protected] wrote:
the image property is UIImage * type which add to FTCoreTextNode class. (BTW, I have do much modification for this project, but I don't how to push my work.)
2012/9/2 KommyKT [email protected]
I modified with yout code, but get an error, for this line: currentSupernode.image = image; and currentSupernode.image = img; the error: Property 'image' not found on object of type 'FTCoreTextNode *'
— Reply to this email directly or view it on GitHubhttps://github.com/FuerteInternational/FTCoreText/issues/12#issuecomment-8221559.
— Reply to this email directly or view it on GitHub.
— Reply to this email directly or view it on GitHub.
I have open a new repository on github. Hope it will help you.
On 2012-9-19, at 下午6:18, KommyKT [email protected] wrote:
Yout can send the modified code by e-mail or any filesharing portal.
On Sep 19, 2012, at 8:19 AM, dourgulf [email protected] wrote:
the image property is UIImage * type which add to FTCoreTextNode class. (BTW, I have do much modification for this project, but I don't how to push my work.)
2012/9/2 KommyKT [email protected]
I modified with yout code, but get an error, for this line: currentSupernode.image = image; and currentSupernode.image = img; the error: Property 'image' not found on object of type 'FTCoreTextNode *'
— Reply to this email directly or view it on GitHubhttps://github.com/FuerteInternational/FTCoreText/issues/12#issuecomment-8221559.
— Reply to this email directly or view it on GitHub.
— Reply to this email directly or view it on GitHub.
plz upadate it