Ios 附加字符串的顺序如何在UITextView中禁用滚动?

Ios 附加字符串的顺序如何在UITextView中禁用滚动?,ios,uitextview,Ios,Uitextview,这是一个非常奇怪的问题--我正在通过将NSMutableAttributedString部分附加到一个总体NSMutableAttributedString,然后将UITextView.text设置为该字符串来构建许多UITextView。我在多个其他文本视图中使用了这种方法,没有任何问题 对于我现在正在处理的部分(关于阅读大脑磁共振成像),我试图附加5个字符串。当我按照1,2,3,4的顺序添加它们时,UITextView会正常滚动并显示所有信息。当我添加5时,它在底部截断,并且不滚动。当我将它

这是一个非常奇怪的问题--我正在通过将NSMutableAttributedString部分附加到一个总体NSMutableAttributedString,然后将UITextView.text设置为该字符串来构建许多UITextView。我在多个其他文本视图中使用了这种方法,没有任何问题

对于我现在正在处理的部分(关于阅读大脑磁共振成像),我试图附加5个字符串。当我按照1,2,3,4的顺序添加它们时,UITextView会正常滚动并显示所有信息。当我添加5时,它在底部截断,并且不滚动。当我将它们重新排序为5,2,3,4,1时,UITextView会再次正常滚动。当我将第5个字符串的文本更改为“test”时,它会正常滚动

第5个字符串的文本中是否存在某种干扰UITextView滚动功能的内容?谢谢,我在这里完全不知所措

// Brain MRI

    //Intro
    NSMutableAttributedString * neuroMRI = [[NSMutableAttributedString alloc] initWithString:@"High signal intensity = bright = hyperintense\nLow signal intensity = dark = hypointense\n\nThere are 4 types of images you need to know.\n\n"];
    [neuroMRI addAttribute:NSFontAttributeName value:noteFont range:NSMakeRange(0, neuroMRI.length)];

    //T1 weighted
    NSMutableAttributedString * neuroMRI1 = [[NSMutableAttributedString alloc] initWithString:@"T1 weighted:\nFluid = low signal intensity\n\n\u2022Fat = white\n\u2022White matter = gray\n\u2022Gray matter = darker gray\n\u2022Fluid = very dark gray\n\u2022Air = black\n\n\u2022Good for looking at brain tissue\n\u2022T1 weighted can have gadolinium added, which shows up bright and won’t enter normal brain tissue\n\u2022Gadolinium lights up pathology on T1 imaging\n\u2022This is called a contrast-enhancing lesion: Dark on T1, bright on T1 with gadolinium\n\u2022Contrast-enhancing lesions can be ring-enhancing or homogeneously enhancing\n\n"];
    [neuroMRI1 addAttribute:NSFontAttributeName value:noteFont range:NSMakeRange(0, neuroMRI1.length)];
    [neuroMRI1 addAttribute:NSFontAttributeName value:titleFont range:NSMakeRange(0, @"T1 Weighted:".length)];

    //T2 weighted
    NSMutableAttributedString * neuroMRI2 = [[NSMutableAttributedString alloc] initWithString:@"T2 weighted:\nFluid = high signal intensity\n\n\u2022Fluid = white\n\u2022Gray matter = light gray\n\u2022White matter = gray\n\u2022Fat = black\n\n\u2022Good for looking at CSF spaces\n\n"];
    [neuroMRI2 addAttribute:NSFontAttributeName value:noteFont range:NSMakeRange(0, neuroMRI2.length)];
    [neuroMRI2 addAttribute:NSFontAttributeName value:titleFont range:NSMakeRange(0, @"T2 Weighted:".length)];

    //Flair
    NSMutableAttributedString * neuroMRI3 = [[NSMutableAttributedString alloc] initWithString:@"Flair:\n\u2022Looks like T2 with dark CSF\n\u2022Most sensitive for edema\n\u2022Good at seeing pathology\n\n"];
    [neuroMRI3 addAttribute:NSFontAttributeName value:noteFont range:NSMakeRange(0, neuroMRI3.length)];
    [neuroMRI3 addAttribute:NSFontAttributeName value:titleFont range:NSMakeRange(0, @"Flair:".length)];

    //Diffusion weighted
    NSMutableAttributedString * neuroMRI4 = [[NSMutableAttributedString alloc] initWithString:@"Diffusion weighted:\n\u2022Used to visualize areas of ischemia (visible almost immediately)\n\u2022Stroke is light on diffusion-weighted imaging, dark on diffusion ADC map\n\n"];
    [neuroMRI4 addAttribute:NSFontAttributeName value:noteFont range:NSMakeRange(0, neuroMRI4.length)];
    [neuroMRI4 addAttribute:NSFontAttributeName value:titleFont range:NSMakeRange(0, @"diffusion Weighted:".length)];

    //Dating a stroke on MRI
    NSMutableAttributedString * neuroMRI5 = [[NSMutableAttributedString alloc] initWithString:@"How to date a stroke using T1 and T2:\n\n\u2022Hyperacute (< 24 hrs): T1 isointense, T2 hyperintense (due to intracellular oxyhemoglobin)\n\u2022Acute (1-3 days): T1 isointense, T2 hypointense (due to intracellular deoxyhemoglobin)\n\u2022Early subacute (3-7 days): T1 hyperintense, T2 hypointense (due to intracellular methemoglobin)\n\u2022Late subacute (7-28 days): T1 hyperintense, T2 hyperintense (due to extracellular methemoglobin)\n\u2022Chronic (> 28 days): T1 hypointense, T2 hypointense (due to hemosiderin)"];
    [neuroMRI5 addAttribute:NSFontAttributeName value:noteFont range:NSMakeRange(0, neuroMRI5.length)];
    [neuroMRI5 addAttribute:NSFontAttributeName value:titleFont range:NSMakeRange(0, @"How to date a stroke using T1 and T2:".length)];

    [neuroMRI appendAttributedString:neuroMRI1];
    [neuroMRI appendAttributedString:neuroMRI2];
    [neuroMRI appendAttributedString:neuroMRI3];
    [neuroMRI appendAttributedString:neuroMRI4];
    [neuroMRI appendAttributedString:neuroMRI5];

    neuroMRIText.attributedText = neuroMRI;
//脑磁共振成像
//介绍
NSMutableAttributedString*neuroMRI=[[NSMutableAttributedString alloc]initWithString:@“高信号强度=高信号强度\nLow信号强度=暗信号强度=低信号强度\n\n您需要知道4种图像类型。\n\n”];
[neuroMRI addAttribute:NSFontAttributeName值:noteFont范围:NSMakeRange(0,neuroMRI.length)];
//T1加权
NSMUTABLeAttributeString*neuroMRI1=[[NSMUTABLeAttributeString alloc]initWithString:@"T1加权:\n流体=低信号强度\n\n\u2022Fat=白色\n\u2022White matter=灰色\n\u2022Gray matter=深灰色\n\u2022Fluid=极深灰色\n\u2022Air=黑色\n\u2022gair=黑色\n\u2022Gadolinium可以添加钆,显示明亮,不会进入正常脑组织\n\u2022Gadolinium亮起T1成像病理学\n\u2022这被称为对比增强病变:T1暗,T1亮,含钆\n\u2022对比增强病变可以是环形增强或均匀增强\n\n“];
[neuroMRI1 addAttribute:NSFontAttributeName值:noteFont范围:NSMakerRange(0,neuroMRI1.length)];
[neuroMRI1 addAttribute:NSFontAttributeName值:标题范围:NSMakeRange(0,@“T1加权:.length)];
//T2加权
NSMutableAttributedString*neuroMRI2=[[NSMutableAttributedString alloc]initWithString:@“T2加权:\nFluid=高信号强度\n\n\u2022Fluid=白色\n\u2022Gray matter=浅灰色\n\u2022White matter=灰色\n\u2022Fat=黑色\n\n\u2022适合查看CSF空间\n\n”];
[neuroMRI2 addAttribute:NSFontAttributeName值:noteFont范围:NSMakerRange(0,neuroMRI2.length)];
[neuroMRI2 addAttribute:NSFontAttributeName值:标题范围:NSMakeRange(0,@“T2加权:.length)];
//天赋
NSMutableAttributedString*neuroMRI3=[[NSMutableAttributedString alloc]initWithString:@“天赋:\n\u2022眼睛像T2一样,脑脊液颜色深\n\u2022对水肿最敏感\n\u2022病理检查良好\n\n”];
[neuroMRI3 addAttribute:NSFontAttributeName值:noteFont范围:NSMakerRange(0,neuroMRI3.length)];
[neuroMRI3 addAttribute:NSFontAttributeName值:标题范围:NSMakeRange(0,@“天赋:.length)];
//扩散加权
NSMutableAttributedString*neuroMRI4=[[NSMutableAttributedString alloc]initWithString:@“扩散加权:\n\u2022用于可视化缺血区域(几乎立即可见)\n\u2022扩散加权成像时行程为浅,扩散ADC图上行程为暗\n\n”];
[neuroMRI4 addAttribute:NSFontAttributeName值:noteFont范围:NSMakerRange(0,neuroMRI4.length)];
[neuroMRI4 addAttribute:NSFontAttributeName值:标题范围:NSMakeRange(0,@“扩散加权:.length)];
//在核磁共振成像上确定中风的年代
NSMutableAttributedString*neuroMRI5=[[NSMutableAttributedString alloc]initWithString:@“如何使用T1和T2确定中风日期:\n\n\u2022超急性(<24小时):T1等信号,T2高信号(由于细胞内氧合血红蛋白)\n\u2022急性(1-3天):T1等信号,T2低信号(由于细胞内脱氧血红蛋白)\n\u2022早期亚急性(3-7天):T1高信号,T2低信号(由于细胞内高铁血红蛋白)\n\u2022亚急性(7-28天):T1高信号,T2高信号(由于细胞外高铁血红蛋白)\n\u2022慢性(>28天):T1低信号,T2低信号(由于含铁血黄素)”;
[neuroMRI5 addAttribute:NSFontAttributeName值:noteFont范围:NSMakerRange(0,neuroMRI5.length)];
[neuroMRI5 addAttribute:NSFontAttributeName值:titleFont范围:NSMakerRange(0,@“如何使用T1和T2确定中风日期:”.length)];
[神经MRI附录属性字符串:neuroMRI1];
[神经MRI附录属性字符串:neuroMRI2];
[神经MRI附录属性字符串:neuroMRI3];
[神经MRI附录属性字符串:neuroMRI4];
[神经MRI附录属性字符串:neuroMRI5];
neuroMRIText.attributedText=神经MRI;

您的嵌入图像没有显示。谢谢:-我修复了它,我刚刚用
UIFont*noteFont=[UIFont-systemFontOfSize:16.0];
UIFont*titleFont=[UIFont-systemFontOfSize:20.0]
…滚动效果很好。这对于字体来说是准确的。我不确定发生了什么——可能只是我的电脑?我试着重新启动电脑和xcode,但仍然遇到同样的问题。有什么想法吗?如果你用你所使用的代码创建一个新项目,几乎只有一个
UITextView
,你会看到同样的问题吗在此处重新显示?此外,您显示的顶部图像看起来与其他图像一样,文本视图/超级视图的大小与屏幕底部的大小不完全相同…如果在该状态下检查层次结构,您会看到任何奇怪的情况吗?您嵌入的图像不会显示。谢谢!-我已修复此问题,我刚刚用
UIFont*noteFont=[UIFont systemFontOfSize:16.0];
UIFont*titleFont=[UIFont systemFontOfSize:20.0];
…滚动效果很好。这对字体来说是准确的。我不是