如何在quickblox iOS代码中实现贴纸

时间:2017-01-07 11:32:10

标签: ios objective-c iphone quickblox

我正在将贴纸整合到我的chatviewcontroller中。

但是我无法理解如何才能推进它。在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];
}

这是我需要在聊天时为输入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
}

委托中的代码是什么。

请建议。

2 个答案:

答案 0 :(得分:1)

我们可以通过以下步骤添加贴纸,我已添加了类似我们可以添加传入

i)创建一个名为QMChatStickerOutGoingCell的单元格,并具有imageView属性say 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
}

答案 1 :(得分:0)

当用户从'stickerviewcontroller'选择贴纸时,会调用didSelectStickerWithMessage委托。  使用此委托方法从贴纸视图控制器接收贴纸消息并使用UIImageView ( UIImageView+Stickers.h)显示: -

- (void)stk_setStickerWithMessage: (NSString*)stickerMessage completion: (STKCompletionBlock)completion;

我希望你理解上面的答案,你可以询问查询更多细节。