Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS6中NSAttributedString和相应NSString的长度不同_Ios_Objective C_Cocoa Touch_Ios6_Uitextview - Fatal编程技术网

iOS6中NSAttributedString和相应NSString的长度不同

iOS6中NSAttributedString和相应NSString的长度不同,ios,objective-c,cocoa-touch,ios6,uitextview,Ios,Objective C,Cocoa Touch,Ios6,Uitextview,我正在使用。 我不得不对它进行一些定制,但没有重大变化。 我正在使用DTCoreText设置将html转换为NSAttributedString,并将其显示在上面提到的名为RichTextEditor的UITextView的子类中。 问题是: 如果我用段落创建字符串(用'\n'分隔),则richTextEditor.attributedText.string的长度与richTextEditor.text的不同之处如下: (lldb) **po [self.attributedText.strin

我正在使用。 我不得不对它进行一些定制,但没有重大变化。 我正在使用
DTCoreText
设置将
html
转换为
NSAttributedString
,并将其显示在上面提到的名为
RichTextEditor
UITextView
的子类中。 问题是: 如果我用段落创建字符串(用
'\n'
分隔),则
richTextEditor.attributedText.string
的长度与
richTextEditor.text
的不同之处如下:

(lldb) **po [self.attributedText.string stringByReplacingOccurrencesOfString:@"\n" withString:@"\\\n\n"]**  
Grftfvtfc\n  
Difg hdfigdfg df\n  
Hgcytvuyg\n  
Sdkjf sdfs sdf klsdf sf kjsdfk s fsdfh s'dfjshdf sdfjshdf sdjfh sdfsjd sdf\n  
Sdfj sdkfjsdl[kak sdfkjsdk sdfksd' kh'dfjs sfsdfsdfsdfUfvutfvuggvjgfc\n  


(lldb) **po [self.text stringByReplacingOccurrencesOfString:@"\n" withString:@"\\\n\n"]**  
Grftfvtfc\n  
\n  
Difg hdfigdfg df\n  
\n  
Hgcytvuyg\n  
\n  
Sdkjf sdfs sdf klsdf sf kjsdfk s fsdfh s'dfjshdf sdfjshdf sdjfh sdfsjd sdf\n  
\n  
Sdfj sdkfjsdl[kak sdfkjsdk sdfksd' kh'dfjs sfsdfsdfsdfUfvutfvuggvjgfc
有时
richTextEditor.text
有两个
'\n'
符号,但在文档末尾,它甚至可能不包含一个
'\n'

此错误仅与
iOS6
相关。在
iOS7
下,一切都像一个符咒。可能的原因是什么


提前谢谢。

看来,这件事是在
NSParagraphStyle
及其属性paragraphspace中。如果足够大,文本视图会添加额外的
\n
符号以增加段落之间的距离,但字符串本身不包含这些
\n