Упорядоченный список HTML в UITextView

Я пытаюсь установить текст HTML с упорядоченным списком для UITextView.

NSString *bodyText = "Please follow the below points:<br><ol><li>Point number one.</li><br><li>Point number two.<br><br>Note:<br>There is point to note here.</li><br><li>Point number three.</li></ol>";

NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:[bodyText dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType} documentAttributes:nil error:nil];

self.bodyTextView.attributedText = attributedString;

Выше приведен текст HTML, который я хотел бы установить в своем UITextView. Ожидаемый результат на моем экране должен быть что-то вроде

Please follow the below points:

    1. Point number one.

    2. Point number two.

       Note:
       There is point to note here.

    3. Point number three.

Но мой результат, который я вижу на экране,

Please follow the below points:

    1. Point number one.
    2.
    3. Point number two.

       Note:
       There is point to note here.
    4.
    5. Point number three.

В чем проблема? Как я мог преодолеть это? Я не должен изменять текст HTML. Как бы я справился с делом из приложения?

Заранее спасибо!

1 ответ

Ваш HTML это проблема. Там не должно быть никаких <br> теги между элементами списка. Внутри элемента списка все в порядке, но не между ними.

Удалите два ненужных <br> теги и ваш вывод будет правильным.

Другие вопросы по тегам