2016-02-27 58 views

回答

2

要發送帶附件的消息,您應該使用與使用文本發送常規消息相同的方式,但添加附件對象。

var imageData: NSData = UIImagePNGRepresentation(UIImage(named: "arrow.png")!)! 
QBRequest.TUploadFile(imageData, fileName: "arrow.png", contentType: "image/png", isPublic: false, successBlock: {(response: QBResponse!, uploadedBlob: QBCBlob!) in 
    // Create and configure message 
    var message: QBChatMessage = QBChatMessage() 

    var uploadedFileID: UInt = uploadedBlob.ID 
    var attachment: QBChatAttachment = QBChatAttachment() 
    attachment.type = "image" 
    attachment.ID = String(uploadedFileID) 
    message.attachments = [attachment] 
    // Send message 
    }, statusBlock: {(request: QBRequest?, status: QBRequestStatus?) in 

    }, errorBlock: {(response: QBResponse!) in 
     NSLog("error: %@", response.error) 
}) 

有一個完整的工作示範項目,可以做你想要的here

+0

你能告訴我如何顯示該單元格上的加載器微調器,直到圖像不傳輸? –

相關問題