我正在将贴纸集成到我的聊天 View Controller 中。
但我无法理解如何推进它,Quickblox 文档中提供了一些代码片段,但我很困惑在哪里放置代码以及如何处理贴纸。在此处输入代码
https://quickblox.com/developers/SimpleSample-chat_users-ios#Stickers
1 . pod "StickerPipe" - Done
2 . [STKStickersManager initWitApiKey:@"API_KEY"]; - Done
3. if ([STKStickersManager isStickerMessage:message]) {
[self.stickerImageView stk_setStickerWithMessage:message placeholder:nil placeholderColor:nil progress:nil completion:nil];
}
这是我需要为聊天中的输入 TextView 编写的代码吗?以及如何
@property (strong, nonatomic) STKStickerController *stickerController;
self.inputTextView.inputView = self.stickerController.stickersView;
[self reloadStickersInputViews];
写了属性,但不知道如何处理贴纸
5。
- (void)stickerController:(STKStickerController *)stickerController didSelectStickerWithMessage:(NSString *)message {
//Send sticker message
}
委托(delegate)内的代码是什么。
请建议。
我们可以通过以下步骤添加贴纸,我已经为传出添加了类似的贴纸,我们也可以为传入添加
i) 创建一个名为 QMChatStickerOutGoingCell 的单元格,并具有 imageView 属性,例如 StickerImageView
ii)ChatViewController(QMChatViewController 的子类)需要知道 QMChatStickerOutGoingCell 的单元格类型,以便我们可以像下面一样执行
- (Class)viewClassForItem:(QBChatMessage *)item {
if ([STKStickersManager isStickerMessage: item.text]) {
return [QMChatStickerOutGoingCell class];
}
//Add condition for other cells
}
iii)更新贴纸
- (void)collectionView:(QMChatCollectionView *)collectionView
configureCell:(UICollectionViewCell *)cell forIndexPath:(NSIndexPath
*)indexPath{
[super collectionView:collectionView configureCell:cell forIndexPath:indexPath];
QMChatCell *chatCell = (QMChatCell *)cell;
// subscribing to cell delegate
[chatCell setDelegate:self];
[chatCell containerView].highlightColor = [UIColor colorWithWhite:0.5 alpha:0.5];
QBChatMessage *message = [self.chatDataSource messageForIndexPath:indexPath];
if ([cell isKindOfClass:[QMChatStickerOutGoingCell class]]){
[chatCell containerView].bgColor = [UIColor redColor];
[(QMChatStickerOutGoingCell *)chatCell fillWithStickerMessage: message.text downloaded: [self.stickerController isStickerPackDownloaded: message.text]];
}
//Handle for other cells
}
Tôi là một lập trình viên xuất sắc, rất giỏi!