这是一个非常奇怪的问题 - 我通过将NSMutableAttributedString部分附加到一个总体NSMutableAttributedString,然后将我的UITextView.text设置为等于该字符串,构建了许多UITextView。我已经使用过这种方法而没有出现任何其他TextView的问题,并且没有任何问题。
对于我现在正在研究的部分(在阅读脑部核磁共振成像),有5个字符串我试图追加。当我按顺序1,2,3,4附加它们时,UITextView正常滚动并显示所有信息。当我添加5时,它会在底部切断并且不会滚动。 当我将它们重新排序为5,2,3,4,1时,UITextView会再次滚动。 当我将第5个字符串的文本更改为"测试测试测试"它滚动正常。
第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;