subharb
subharb

Reputation: 3472

Objective-C - Show avatar picture from XMPPvCardAvatarModule in XEP 153?

I'm developing an iphone app with XMPP.

I'm trying to print the images of the logged in users in the chat room. This is the code I have.

XMPPvCardAvatarModule *avatar = [[XMPPvCardAvatarModule alloc]initWithvCardTempModule:[[self appDelegate]xmppvCardTempModule]];
XMPPJID *jidUser = [XMPPJID jidWithString:key];
NSData *foto = [[NSData alloc]initWithData:[avatar photoDataForJID:jidUser]];UIImage *pic = [UIImage imageWithData:fotoData];
UIImageView *picVista = [[UIImageView alloc] initWithImage:pic];

[self.commentsGente addSubview:picVista];

But that NSData is always 0KB, so there's obviously no image. How to do this?

Upvotes: 0

Views: 1118

Answers (1)

arunKumara O D
arunKumara O D

Reputation: 56

NSData *photoData = [[[self appDelegate] xmppvCardAvatarModule]photoDataForJID:user.jid];

UIImageView *picVista;
picVista.image = [UIImage imageWithData:photoData];

try this it works fine for me

Upvotes: 4

Related Questions