Saturday, 15 June 2013

objective c - ios How to add UIImage to UITextView asynchronous? -



objective c - ios How to add UIImage to UITextView asynchronous? -

i can add together image asynchronously seperately using uiimageview+afnetworking

[imageview setimagewithurl:[nsurl urlwithstring:[self.data valueforkey:@"image_link"]]];

i can add together image uitextview by

uitextview *text = [[uitextview alloc] init]; uiimageview *imageview = [uiimageview new]; [imageview setimage:[uiimage imagenamed:@"image.png"]]; cgrect arect = cgrectmake(0, 0, 125, 120); [imageview setframe:arect]; uibezierpath *exclusionpath = [uibezierpath bezierpathwithrect:arect]; text.textcontainer.exclusionpaths = @[exclusionpath]; [text addsubview:imageview];

but cannot add together image asynchronously in uitextview like

uitextview *text = [[uitextview alloc] init]; uiimageview *imageview = [uiimageview new]; [imageview setimagewithurl:[nsurl urlwithstring:[self.data valueforkey:@"image_link"]]]; cgrect arect = cgrectmake(0, 0, 125, 120); [imageview setframe:arect]; uibezierpath *exclusionpath = [uibezierpath bezierpathwithrect:arect]; text.textcontainer.exclusionpaths = @[exclusionpath]; [text addsubview:imageview];

so how can add together image asynchronously in uitextview?

use dispatch :

dispatch_async(dispatch_get_main_queue(), ^{ // async ui update here });

ios objective-c asynchronous uiimage uitextview

No comments:

Post a Comment