Rich Text Input / Editing?

Discussion in 'iOS Programming' started by ArtOfWarfare, Dec 25, 2009.

  1. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #1
    Okay, so it seems that the method Apple recommends for displaying rich text on the iPhone is through using a UIWebView. This is fine and all, except I'd like users to be able to intuitively be able to write and edit rich text.

    I'm really at a loss for how I'd go about that. Like...

    let's say I set up a UIWebView... and in that I had just a string with some text with a few words bolded.

    And then I set up a UIButton for bolding.

    What exactly should the button do? Somehow I'd need to figure out what text the user has selected in the UIWebView... and somehow I'll need to figure out how to send a method to bold to the UIWebView...

    Wait...

    am I going to have to learn how to use JavaScript or something? I was really hoping I wouldn't have to learn an entire new language in addition to Obj-C...

    If I have to learn JavaScript, can someone point me in the direction of a few lessons.

    And if not, can someone suggest a better method.
     
  2. miep macrumors newbie

    Joined:
    Jul 6, 2007
    #2
    Yep, DISPLAY. I don't think you'd be well off using UIWebView for text editing, like you want to.

    Never implemented it, but I'd probably go for a UITextView box, where the user enters 'raw' text without formatting. That one does allow you to respond to user input.

    Then, if a user selects word #3 in line #2, and clicks 'bold', mark in an internal buffer that the selected letters should all be bold. And then update a uiwebview to DISPLAY said content.

    You'd end up with two boxes, one which has the user input, one that has the result of the rich text editing. Not that different from the type of box I'm using to enter this message, though...
     
  3. Saladinos macrumors 68000

    Saladinos

    Joined:
    Feb 26, 2008
    #3
    Yup, rich text is a pain on the iPhone. The platform may be popular, but it's not flawless.

    For example, why is there no dark activity spinner? You get to choose between light grey, white, or large white. If you want to show a spinner on a light background, you're out of luck.
     
  4. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #4
    Rich text editing on iPhone is not an easy task. I would recommend looking at the three twenty code. They have some classes for display of rich text, don't know if they have an editor. I would search for open source javascript code for this purpose. You might find something.

    Otherwise, building something like this from scratch is a hard task.
     
  5. North Bronson macrumors 6502

    Joined:
    Oct 31, 2007
    Location:
    San José
    #5
    You might find a few ideas in the "Utility" template (browser-based rich-text editor) for Dashcode.
     

Share This Page