作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在将贴纸集成到我的聊天 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
}
关于ios - 我如何在 Quickblox iOS 代码中实现贴纸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41520964/
我是一名优秀的程序员,十分优秀!