2
A
回答
5
我不相信有一個函數您可以重寫以獲得所需的結果。但另一方面,如果你想分叉JSQMessageViewController並自己修改它。如果你到源項目去jSQMessages/JSQMessagesViewController /型號/的mediaView下JSQPhotoMediaItem.m在線路74
if (self.cachedImageView == nil) {
CGSize size = [self mediaViewDisplaySize];
UIImageView *imageView = [[UIImageView alloc] initWithImage:self.image];
imageView.frame = CGRectMake(0.0f, 0.0f, size.width, size.height);
imageView.contentMode = UIViewContentModeScaleToFill;
imageView.clipsToBounds = YES;
[JSQMessagesMediaViewBubbleImageMasker applyBubbleImageMaskToMediaView:imageView isOutgoing:self.appliesMediaViewMaskAsOutgoing];
self.cachedImageView = imageView;
}
開始,如果你改變線路78 imageView.contentMode = UIViewContentModeScaleAspectFit;
到imageView.contentMode = UIViewContentModeScaleToFill;
如果添加imageView.backgroundColor = [UIColor lightGrayColor];
你將有泡沫形狀也。以下是前後的一些屏幕截圖。
2
確定 這裏我的代碼:
override func viewDidLoad() {
super.viewDidLoad()
self.collectionView?.collectionViewLayout.outgoingAvatarViewSize = CGSizeZero
self.collectionView?.collectionViewLayout.incomingAvatarViewSize = CGSizeZero
self.inputToolbar?.contentView?.rightBarButtonItemWidth = CGFloat(34.0)
self.inputToolbar?.contentView?.rightBarButtonItem?.setTitle("Invia", forState: .Normal)
self.inputToolbar?.contentView?.textView!.placeHolder = "messaggio.."
setUpMessages()
// Do any additional setup after loading the view.
}
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.messages.count
}
override func collectionView(collectionView: JSQMessagesCollectionView!, messageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageData! {
return self.messages[indexPath.item]
}
override func collectionView(collectionView: JSQMessagesCollectionView!, messageBubbleImageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageBubbleImageDataSource! {
let factory = JSQMessagesBubbleImageFactory()
if messages[indexPath.row].senderId == senderId {
return factory.outgoingMessagesBubbleImageWithColor(UIColor.lightGrayColor())
} else {
return factory.incomingMessagesBubbleImageWithColor(UIColor.greenColor())
}
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = super.collectionView(collectionView, cellForItemAtIndexPath: indexPath)
let message = self.messages[indexPath.row]
return cell
}
override func collectionView(collectionView: JSQMessagesCollectionView!, avatarImageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageAvatarImageDataSource! {
return nil
}
func setUpMessages() {
//load text messages:
let mes1: JSQMessage = JSQMessage(senderId: "10", displayName: "io10", text: "Ciao")
let mes2: JSQMessage = JSQMessage(senderId: "10", displayName: "io10", text: "Ciao2")
let mes3: JSQMessage = JSQMessage(senderId: "10", displayName: "io10", text: "Ciao3")
let mes4: JSQMessage = JSQMessage(senderId: "10", displayName: "io10", text: "Ciao4")
messages.append(mes1)
messages.append(mes2)
messages.append(mes3)
messages.append(mes4)
//load image message
let img2 = JSQPhotoMediaItem(image: UIImage (named: "default"))
let mes5 = JSQMessage(senderId: "10", senderDisplayName: "io10", media: img2)
messages.append(mes5)
}
+0
正是我所需要的,我被捲入Ocj-C文檔和語法 – Sauron
相關問題
- 1. 如何在圖像中顯示信息消息
- 2. Slack消息JSON,圖像不顯示
- 3. 在c#中上傳圖像並在wpf中顯示消息框
- 4. 如何在jsp中的警報/消息框中顯示圖像
- 5. 在視圖中顯示Yii2 HttpException消息
- 6. 在ExtJs中顯示消息
- 7. 在c中顯示消息#
- 8. 我試圖從phpmyadmin數據庫中顯示圖像和消息
- 9. 顯示消息
- 10. 顯示消息
- 11. 顯示消息
- 12. 顯示消息
- 13. 顯示消息
- 14. 顯示消息
- 15. 顯示消息
- 16. 顯示消息
- 17. 顯示消息
- 18. 如何在wp_mail函數的消息部分顯示圖像?
- 19. JavaScript顯示圖像和文字而不是提示消息
- 20. 消息以顯示在PHP
- 21. 顯示消息框在JavaScript
- 22. 在GUI上顯示消息
- 23. setfocus在消息顯示
- 24. 取消圖像不顯示在uploadify
- 25. 顯示消息SSJS
- 26. 顯示消息框
- 27. jQuery顯示消息
- 28. JOptionPane顯示消息
- 29. 顯示simple_form消息
- 30. MFC - 顯示消息
你是怎麼得到的圖像加載? github源碼? – Sauron