gpt4 book ai didi

ios - UITextView 中的属性文本导致崩溃

转载 作者:可可西里 更新时间:2023-11-01 05:12:36 25 4
gpt4 key购买 nike

这是我在 UITextView 中显示属性字符串的代码

NSMutableAttributedString *recipeString =[[NSMutableAttributedString alloc]init];
[recipeString appendAttributedString:string1];
[recipeString appendAttributedString:string2];
[array addObject:recipeString];

此代码在 for 循环中。 string1string2NSMutableAttributedString

之后:

self.textView.text = [array objectAtIndex:self.appDelegate.selectedCell];

TextView 是一个IBOutlet

它因以下异常而崩溃:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteAttributedString _isCString]: unrecognized selector sent to instance 0x8e866f0'

关于如何解决这个崩溃有什么想法吗?

最佳答案

我必须使用 UITextViewattributedText 属性:

self.textView.attributedText = [array objectAtIndex:self.appDelegate.selectedCell];

关于ios - UITextView 中的属性文本导致崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23181759/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com