Get writing language of “uitextview” iphone?

2020-04-16 05:32发布

How can i get writing language of uitextview? or how can i know uitextview is right to left or left to right in current state?

3条回答
混吃等死
2楼-- · 2020-04-16 06:24
[textView baseWritingDirectionForPosition:[textView beginningOfDocument] inDirection:UITextStorageDirectionForward] == UITextWritingDirectionRightToLeft

Should return true if the UITextView is right-to-left, and false otherwise.

Further documentation can be found here, if you need it!

查看更多
我只想做你的唯一
3楼-- · 2020-04-16 06:25

In answer to your other question, you can get the keyboard language used from UITextInputMode docs: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextInputMode_Class/Reference/Reference.html

查看更多
贪生不怕死
4楼-- · 2020-04-16 06:26

This solution worked better for me

[NSLocale characterDirectionForLanguage:self.textView.textInputMode.primaryLanguage] == NSLocaleLanguageDirectionRightToLeft
查看更多
登录 后发表回答