Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

图文混排的一个问题 #189

Open
Sdoy opened this issue Mar 4, 2016 · 3 comments
Open

图文混排的一个问题 #189

Sdoy opened this issue Mar 4, 2016 · 3 comments

Comments

@Sdoy
Copy link

Sdoy commented Mar 4, 2016

image

图文混排的时候selectionView可以定在此位置,但是只要一输入selectionView就换行跑到下面去了,很影响使用体验,在demo中测试也是这样,点q处光标还是能回去,但是再输入光标又跑下去了,请问我该如何做,能使光标不跑到图片前面

image

@ibireme
Copy link
Owner

ibireme commented Mar 4, 2016

修改光标位置可以这样:

UITextRange *range = [YYTextRange rangeWithRange:textView.selectedRange affinity:YYTextAffinityForward];
[textView setSelectedTextRange:range];

其中 YYTextAffinityForward 表示光标在字符前,YYTextAffinityBackward 表示光标在字符后。

至于自动调整位置这个,以后会尝试做一下优化。

@Sdoy
Copy link
Author

Sdoy commented Mar 7, 2016

如果用self.textView.exclusionPaths来做插入图片,在最后解析成文本传给后台的时候,是不是不好拿到图片插入的rang?

@ibireme
Copy link
Owner

ibireme commented Mar 7, 2016

遍历 textLayout.lines 然后一点点算出来。。是很麻烦。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants