简体   繁体   English

如何在iPhone UITextView或UITextField中更改书写方向

[英]How to change the writing direction in iPhone UITextView or UITextField

Right now if you type something in a right to left language and tap and hold, the copy and paste menu will have an extra option for changing the writing direction form "left to right" to "right to left". 现在,如果您用从右到左的语言键入内容并点击并按住,则复制和粘贴菜单将有一个额外的选项,用于将书写方向从“从左到右”更改为“从右到左”。

I want to set this option in the code so that my UITextView writing direction would be right to left by default. 我想在代码中设置此选项,以便我的UITextView写入方向默认为从右到左。

Does anyone know how I can do that. 有谁知道我怎么能这样做。 I searched all over the web and SDK and tried everything with no luck. 我搜索了整个网络和SDK并尝试了一切没有运气。 I would be grateful if anyone can help. 如果有人能提供帮助,我将不胜感激。

check may be this will help you. 检查可能会对你有帮助。

setTextAlignment:UITextAlignmentRight; setTextAlignment:UITextAlignmentRight;

Hope this can help 希望这可以提供帮助

divide the text in the UITextView by line,and change NSString from "left to right" to "right to left" is quite simple 逐行划分UITextView中的文本,并将NSString从“从左到右”更改为“从右到左”非常简单

如果你想在uitextview中从右到左设置文字书写方向

"your UITextview".makeTextWritingDirectionRightToLeft(true)

I think you can use something like: 我想你可以使用类似的东西:

Swift: 迅速:

func makeTextWritingDirectionRightToLeft(_ sender: Any?)

Objective C: 目标C:

(void)makeTextWritingDirectionRightToLeft:(id)sender;

Look it up in the Method Reference 在“方法参考”中查找

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM