0
我正在嘗試使用圖層和地圖集sdk聊天應用程序的示例,我從github下載了示例,並且我希望每個用戶都可以從應用中設置其頭像。所以它在聊天時顯示。使用圖層地圖集sdk設置頭像圖片
我試圖編輯的應用程序使用方法來生成頭像取決於用戶的名稱,但我不想這樣。
的Class IM編輯爲ATLMUser
:
- (NSString *)avatarInitials
{
NSMutableString *initials = [NSMutableString new];
NSString *nameComponents = [self.fullName stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSArray *names = [nameComponents componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if (names.count > 2) {
NSString *firstName = names.firstObject;
NSString *lastName = names.lastObject;
names = @[firstName, lastName];
}
for (NSString *name in names) {
[initials appendString:[name substringToIndex:1]];
}
return initials;
}
存在着方法的類來設置圖像,但它返回nil,如:
- (UIImage *)avatarImage
{
return nil;
}
- (NSURL *)avatarImageURL
{
return nil;
}
如何編輯類,使每個對象設置自己的頭像。
退房這裏的樣本:https://github.com/layerhq/Atlas-iOS
你如何設置羣聊一個默認的頭像? –
@ T.Rex您的'ConversationListViewController'應該實現'ATLConversationListViewControllerDataSource'協議。看看[文檔](http://cocoadocs.org/docsets/Atlas/1.0.0/Protocols/ATLConversationListViewControllerDataSource.html#//api/name/conversationListViewController:avatarItemForConversation :)。另外檢查[這個例子](https://github.com/layerhq/Atlas-Messenger-iOS/blob/4b6ab70dfd62f6de3aadc5774b146d670c17df0f/Code/Controllers/ATLMConversationListViewController.m#L111)。 –
@ T.Rex你可以做一些類似於我鏈接的例子。尋找參與者的數量,如果它是一個組返回您的默認頭像。它應符合[ATLAvatarItem](http://cocoadocs.org/docsets/Atlas/1.0.1/Protocols/ATLAvatarItem.html)協議。 –