Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 将文字信息与图像组合在一个气泡中_Ios_Swift_Jsqmessagesviewcontroller - Fatal编程技术网

Ios 将文字信息与图像组合在一个气泡中

Ios 将文字信息与图像组合在一个气泡中,ios,swift,jsqmessagesviewcontroller,Ios,Swift,Jsqmessagesviewcontroller,如何将图像和文本组合成这样的气泡 目前,我唯一能做到的就是用 let mediaItem = ChatImageJSQPhoto(image: image) let outgoingBool = chat.sender!.id != NetworkHelper.loggedInUser!.id mediaItem.appliesMediaViewMaskAsOutgoing = outgoingBoo

如何将图像和文本组合成这样的气泡

目前,我唯一能做到的就是用

                let mediaItem = ChatImageJSQPhoto(image: image)
                let outgoingBool = chat.sender!.id != NetworkHelper.loggedInUser!.id
                mediaItem.appliesMediaViewMaskAsOutgoing = outgoingBool
                let photoMessage = JSQMessage(senderId: String(chat.sender!.id), senderDisplayName: chat.sender!.username, date: self.formatter.dateFromString(chat.dateTime), media: mediaItem)
                Alamofire.request(.GET, chat.gift!.image)
                    .responseImage { response in
                        if let image = response.result.value {
                            mediaItem.image = image

                            dispatch_async(dispatch_get_main_queue(), {
                                self.collectionView.reloadData()
                                self.finishReceivingMessage()
                            })
                        }

                }
                self.messages.append(photoMessage)
                //then get the message if it exists
                if chat.desc.characters.count > 0 {
                    self.addMessage(String(chat.sender!.id), senderName: chat.sender!.username, text: chat.desc, date: chat.dateTime)
                }

您可以使用自动布局来实现这一点。这里只是一个小小的想法,你如何实现你的项目

H:|[imageView]-10-[uiLabel]|


有关自动布局视觉格式语言(VFL)的详细信息,请参见

,以获得旁边有对齐文本的图像。或者您可以使用AttributedString获取带有图像附件的AttributedString如何更改我的JSQ的自动布局?我不必从JSQ中生成任何子类?什么是“JSQ”?您不需要对任何内容进行子类化。只需在自定义单元格类中编写自动布局代码,但我在聊天时使用JSQMessSagesViewControllR