我正在将贴纸集成到我的聊天视图控制器中。
但是我无法理解我该如何推进它,Quickblox文档中提供了一些代码片段,但混淆了代码的放置位置以及如何处理贴纸。enter code here
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];
}
这是我需要在聊天中为输入文本视图编写的代码吗?以及如何
@property (strong, nonatomic) STKStickerController *stickerController;
self.inputTextView.inputView = self.stickerController.stickersView;
[self reloadStickersInputViews];
写了属性,但不确定如何处理贴纸
5 .
- (void)stickerController:(STKStickerController *)stickerController didSelectStickerWithMessage:(NSString *)message {
//Send sticker message
}
委托中的代码是什么.
请建议 .
我们可以按照以下步骤添加贴纸,我已经为传出添加了类似的东西,我们也可以为传入添加
一)创建一个名为 QMChatStickerOutGoingCell 的单元格,并具有 imageView 属性表示 stickerImageView
二)ChatViewController(QMChatViewController的子类)需要知道QMChatStickerOutGoingCell的单元格类型,以便我们可以像下面这样执行
- (Class)viewClassForItem:(QBChatMessage *)item {
if ([STKStickersManager isStickerMessage: item.text]) {
return [QMChatStickerOutGoingCell class];
}
//Add condition for other cells
}
三)更新贴纸
- (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
}
当用户从'stickerviewcontroller'
中选择贴纸时,将调用didSelectStickerWithMessage
委托。 使用此委托方法从贴纸视图控制器接收贴纸消息,并以UIImageView (
UIImageView+Stickers.h)
显示它:-
- (void)stk_setStickerWithMessage: (NSString*)stickerMessage
completion: (STKCompletionBlock)completion;
我希望您理解上面的答案,您可以询问更多详细信息。