Select text and copy from label xamarin forms

大城市里の小女人 提交于 2019-12-11 03:05:01

问题


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.

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!


回答1:


I recently faced the same business requirement. An Editor with Renderers customization on each platform was the solution for me.

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.

Check out my post with full code for Xamarin.Forms. You can also read posts on native Android and native iOS for more details.



来源:https://stackoverflow.com/questions/48165549/select-text-and-copy-from-label-xamarin-forms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!