JSQMessagesViewController icon indicating copy to clipboard operation
JSQMessagesViewController copied to clipboard

Asynchronously setting avatar image

Open dailenspencer opened this issue 10 years ago • 10 comments

Hello,

I have a Parse User class and a column of that class is "ProfilePicture" that holds PFFile's for each user's profile picture. What would be the best way to asynchronously set avatar images inside "avatarImageDataForItemAtIndexPath"??

Thanks

dailenspencer avatar Dec 15 '15 21:12 dailenspencer

set it to the avatarImageView inside cellForItemAtIndexPath

ssuchanowski avatar Dec 17 '15 15:12 ssuchanowski

Thanks @ssuchanowski

I keep getting "unexpectedly found nil while unwrapping an optional value". Do I need to register a nib for my view controller and if so, which one?

dailenspencer avatar Dec 17 '15 17:12 dailenspencer

Screenshot: screenshot 2015-12-17 12 19 25

dailenspencer avatar Dec 17 '15 17:12 dailenspencer

@ssuchanowski @jessesquires I was able to accomplish my goal. However, now after sending a message, the collectionview refreshes itself, and thus, refreshes the UIImageView holding the profile picture as well.This makes the page look very glitchy. Is there any way to not have the uiimage view be refreshed?

dailenspencer avatar Dec 24 '15 06:12 dailenspencer

Figured it out

dailenspencer avatar Dec 24 '15 08:12 dailenspencer

A gentle suggestion: on a board dedicated to sharing, helping out, offering code etc, to come asking for advice and to not properly conclude a self-corrected thread with a solution, or a link or even a hint is considered, at least in my office, poor etiquette..

wdcurry avatar Dec 24 '15 14:12 wdcurry

@wdcurry the original question that was posted was answered. Apologies! :)

If anyone gets stuck with this.. The solution was to remove setting the avatar in 'CellForRowAtIndexPath' altogether. The much better method is using 'avatarImageData' . JSQmesages will properly store the images so the need for them to be refreshed is eliminated. Originally, i opted not to use this method because I needed to modify the avatarImageView but I found a workaround for my situation.

dailenspencer avatar Dec 25 '15 19:12 dailenspencer

@dailenspencer could you elaborate your solution please.

harishgonnabattula avatar Jan 26 '17 19:01 harishgonnabattula

@dailenspencer How exactly did you load the image asynchronously in the avatarImageDataForItemAt method? Since that method is synchronous, I'm having trouble figuring out how to tie it all together. Any example code would be nice.

Isuru-Nanayakkara avatar Feb 15 '17 11:02 Isuru-Nanayakkara

@Baam25 @Isuru-Nanayakkara Apologies mates, I no longer have access to the code base I was working on at the time. All I can recall is that, originally, I was attempting to load and set the avatar inside cellForRowAtIndexPath - but then realized the more appropriate solution was to set the image using avatarImageData. I know thats just a reiteration of my previous answer :/

dailenspencer avatar Feb 18 '17 03:02 dailenspencer