FTCoreText icon indicating copy to clipboard operation
FTCoreText copied to clipboard

(request) : be able to load remote images

Open y0hnn opened this issue 12 years ago • 8 comments

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

y0hnn avatar Aug 23 '12 04:08 y0hnn

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:@""];
                }

dourgulf avatar Aug 29 '12 08:08 dourgulf

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?

ghost avatar Sep 02 '12 12:09 ghost

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.

cescofry avatar Sep 02 '12 13:09 cescofry

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.

dourgulf avatar Sep 19 '12 06:09 dourgulf

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.

ghost avatar Sep 19 '12 10:09 ghost

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.

cescofry avatar Sep 19 '12 10:09 cescofry

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.

dourgulf avatar Sep 20 '12 06:09 dourgulf

plz upadate it

PKPranav avatar Jan 21 '14 15:01 PKPranav