【发布时间】:2013-10-15 11:53:39
【问题描述】:
主题说明了一切,所以我会在显示代码后发表评论:
var attr = new CTStringAttributes ();
attr.Font = new CTFont("Parangon110C", 11);
var paragraph = new CTParagraphStyleSettings ();
paragraph.Alignment = CTTextAlignment.Justified;
attr.ParagraphStyle = new CTParagraphStyle(paragraph);
DescLabel.AttributedText = new NSAttributedString(billboard.Desc, attr);
所以在运行这段代码后我得到一个异常
Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[__NSCFType lineBreakMode]: unrecognized selector sent to instance 0xe5a4db0
我发现它只在我设置 attr.ParagraphStyle 时出现。但是当它为空时,一切都很好(除了我无法以我的方式格式化文本,哈哈)。 执行字符串后
DescLabel.AttributedText = new NSAttributedString(billboard.Desc, attr);
调试器在 DescLabel.AttributedText 的 Size 属性中显示异常文本。
我怀疑,这是 CTStringAttributes 或 CTParagraphStyle 中的错误。 我在那里找到了CoreText repository,但直到现在还不能说是哪里出了问题
另外,不久之后,我发现了一个bugreport,有人抱怨他的东西不起作用。但是在纠正了代码中的一个明显错误之后(幸运的家伙),他不再发表评论了,所以结论是:他得到了这个工作。 但他的代码和我的很相似..
请帮助我解决此问题或找到解决方法。 (UIParagraphStyle 也不起作用,它说 UIParagraphStyleSettings.LineBreakMode 设置器没有实现)
【问题讨论】:
-
您指向的来源是用于 mac,而不是 monotouch,但这不是很重要。
标签: c# xamarin.ios mono xamarin