簡體   English   中英

如何在UIInputViewController中發送文本

[英]How to Send Text in an UIInputViewController

所以我有以下代碼來插入文本:

func insert(text: String) {
    (textDocumentProxy as UIKeyInput).insertText(text)
}

但是我實際上如何將其發送到聊天窗口?

如果您要訪問UIInputViewController輸入的所有文本,則以下代碼可能會有所幫助:

var totalText = "" // complete text entered

if let before: String = self.textDocumentProxy.documentContextBeforeInput {
   totalText += before
}

if let after: String = self.textDocumentProxy.documentContextAfterInput {
   totalText += after
}

現在您已經輸入了完整的文本,您可以將其發送到聊天窗口。 如果您正在尋找這些限制,那么我可以分享一些限制。 請告訴我

編輯

要將文本發送到whatsapp ,您需要按custom keyboard extension outsidesend button 如果要將文本輸入到whatsappUITextView中,則非常簡單。 但是, custom keyboard extension無法控制whatsapp的發送按鈕

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM