2016-10-07 4 views
0

решаемые Larme:Как РТФ строка разобрана в Objective C

**[[NSAttributedString alloc] initWithData:[str_rtf dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSRTFTextDocumentType} documentAttributes:nil error:&error]; [yourTextView setAttributedText: attrStr];** 

Я использую WebService и получить RFT формат строки. Но я не могу использовать в строке UITextView rtf.

Возможно преобразование или синтаксис RTF String?

NSString *str_rtf [email protected]"{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf250 
{\fonttbl\f0\fnil\fcharset0 LucidaGrande;\f1\fnil\fcharset0 Monaco;} 
{\colortbl;\red255\green255\blue255;} 
\deftab720 
\pard\pardeftab720\sl264\slmult1\sb260\ql\qnatural 

\f0\fs26 \cf0 You will need to relaunch Xcode after this install to make it load the plugin.\ 
This package installs both version 2.x and 1.x of DMD, but you can customize the install to get only one or the other.\ 
With the two versions installed, D for Xcode uses DMD\'a02.x by default. You can override this setting in your Xcode project on a per-target basis by creating a custom build rule in each target\'92s settings. Alternatively, you can change the system default by typing this command from the terminal:\ 
\pard\pardeftab720\li560\sl264\slmult1\sb260\ql\qnatural 

\f1\fs22 \cf0 sudo setdmd 1 
\f0\fs26 \ 
\pard\pardeftab720\sl264\slmult1\sb260\ql\qnatural 
\cf0 This will change the symlinks to make the 
\f1\fs22 dmd 
\f0\fs26 command point to 
\f1\fs22 dmd1 
\f0\fs26 .}" 

С наилучшими пожеланиями.

+1

Попробуйте с NSAttributedString: https://developer.apple.com/reference/foundation/nsattributedstring/1524613-initwithdata?language=objc – Larme

+0

Привет Я знаю NSAttributedString, но у меня нет образца :( – Jealian

+0

Larme спасибо^^, очень спасибо – Jealian

ответ

0

Попробуйте использовать NSAttributedString с типом документа NSRTFTextDocumentType.

+0

Привет, я знаю, NSAttributedString, но у меня нет образца :( – Jealian

+0

[[NSAttributedString alloc] initWithData: [str_rtf dataUsingEncoding: NSUTF8StringEncoding]: @ {NSDocumentTypeDocumentAttribute: NSRTFTextDocumentType} documentAttributes: nil error: & error] ; [yourTextView setAttributedText: attrStr]; не работает – Jealian

Смежные вопросы