本文介绍了可可触摸的简单的富文本视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个iOS应用程序,其中需要实现具有以下要求的基本文本视图:




  • b $ b

    • 字体强调(粗体,斜体)。

    • 类似超链接操作的内联图片。


      • 滚动

        • 获取和设置滚动偏移量(用于记住上一个滚动位置)。


      • 文字选择

        • 取得所选文字字元范围。





      我相信我可以实现这与 UIWebView 但是这个问题是它提供很少的控制,有点慢,加载时显示一个空白屏幕。我想知道如果这可以实现与核心文本,但关于文本选择我不知道。我希望能够实现作为iOS本地行为尽可能。



      我需要的是很像Instapaper的文本视图。

      解决方案

      OmniGroup通过创建一个类似于 UITextView 的文本编辑器,文本,但也具有 UITextView 的所有编辑功能以及核心文本的富文本功能。



      请查找。


      I'm working on an iOS app in which I need to implement a basic text view with these requirements:

      • Rich text
        • Font emphasis (bold, italics).
        • Inline images for hyperlink-like actions.
      • Scrolling
        • Getting and setting the scroll offset (for remembering the previous scroll position).
      • Text selection
        • Getting the selected text character range.
        • Scrolling the view when selecting text, if needed.

      I believe I could achieve this with UIWebView but the problem with this is that it provides very little control and is somewhat slow and shows a blank screen while loading. I was wondering if this could be achieved with Core Text but regarding the text selection I'm not sure. I'm hoping to achieve as iOS-native behaviour as possible.

      What I'd need is pretty much like Instapaper's text view.

      解决方案

      OmniGroup have done something like this by creating a text editor much like UITextView which draws the text using Core Text but also has all the editing features of UITextView as well as Rich text features from Core Text.

      You can find it here.

      这篇关于可可触摸的简单的富文本视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 06:52