选择文本并从标签xamarin表格中复制 [英] Select text and copy from label xamarin forms
问题描述
几天来,我一直在不同的论坛上阅读有关选择文本并从xamarin形式的标签中复制文本的问题,这似乎并不是实现此问题的直接方法.
I have for some days been reading on different forums about the issue of selecting a text and copying the text natively from a label in xamarin forms and it seems to be no straightforward way of implementing this.
我的问题是我需要在标签中呈现一本书中的大量数据,并且用户应该能够从标签中选择并复制大量文本. 我继续将数据显示在编辑器组件中,但随后用户可以在编辑器中编辑文本.将Editor组件设置为只读也不能解决问题.
My problem is that I need to present a large amount of data from a book in a label and the user should be able to select and copy a chunk of text from the label. I moved on to present the data in an Editor component instead but then the user can edit the text in the Editor. Making the Editor component read-only doesn't solve the problem either.
任何建议将不胜感激!
Any suggestions would be greatly appreciated!
推荐答案
我最近遇到了同样的业务需求.在每个平台上带有Renderers
定制的Editor
是我的解决方案.
I recently faced the same business requirement. An Editor
with Renderers
customization on each platform was the solution for me.
简而言之,Android renderer
利用EditText
的CustomSelectionActionModeCallback
和CustomInsertionActionModeCallback
属性来自定义上下文菜单以进行文本选择和插入,而iOS renderer
非常简单明了,并设置了Selectable
和Editable
UITextView
的属性.
In short, Android renderer
leverages CustomSelectionActionModeCallback
and CustomInsertionActionModeCallback
properties of EditText
to customize context menu for text selection and insertion, while iOS renderer
is pretty straight-forward and sets Selectable
and Editable
properties of UITextView
.
查看我的 post ,其中包含Xamarin.Forms
的完整代码.您还可以在本机上阅读帖子Android 和本机iOS 以获取更多详细信息.
Check out my post with full code for Xamarin.Forms
. You can also read posts on native Android and native iOS for more details.
这篇关于选择文本并从标签xamarin表格中复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!