iphone - Objective C - 在 UITextView 中显示数据

标签 iphone objective-c xcode uitextview exc-bad-access

我在 iPhone 编程中的 UITextView 中显示数据时遇到困难。

我正在分析传入的音频数据(来自麦克风)。为此,我从 SignalAnalyzer 类创建一个对象“分析器”,该对象对传入数据进行分析。我想做的是在 TextView 中实时显示每个新传入的数据。

因此,当我按下按钮时,我会创建对象“分析器”来分析传入的数据。每次有新数据时,我都需要将其显示在屏幕上的 TextView 中。

我的问题是我收到错误,因为(我认为)我正在尝试向父类发送消息(负责在我的 UITextView 中显示内容的父类:它有一个链接到的 UITexView 实例变量界面生成器)。 我应该怎么做才能告诉我的父类它需要显示什么?或者我应该如何设计我的类来自动显示某些内容?

感谢您的帮助。

PS:这是我的错误:

    2010-04-19 14:59:39.360 MyApp[1421:5003] void WebThreadLockFromAnyThread(), 
0x14a890: Obtaining the web lock from a thread other than the main thread 
or the web thread. UIKit should not be called from a secondary thread.

    2010-04-19 14:59:39.369 MyApp[1421:5003] bool _WebTryThreadLock(bool), 
0x14a890: Tried to obtain the web lock from a thread other than the main thread 
or the web thread. This may be a result of calling to UIKit from a secondary thread.
Crashing now...

    Program received signal:  “EXC_BAD_ACCESS”.

最佳答案

看来您的问题是您正在尝试从辅助线程更新 UI,但您不允许这样做。考虑使用 performSelectorOnMainThread: 进行 UI 更新。

关于iphone - Objective C - 在 UITextView 中显示数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2667595/

相关文章:

ios - 更改文本后无法更改 UISearchBar 取消按钮标题颜色。

iphone - 如何在更改 iPhone 方向时保持图像大小

iphone - 执行 segue 时未加载下一个 View Controller

ios - Xcode 10 "Could not build module Darwin/Foundation/CoreFoundation"等

ios - 已辞职的 ipa 在 iOS 8 中安装但未在 iOS 9+ 中安装

ios - 将项目从旧版本的 xcode 转换为新版本

ios - 如何在 Swift 中限制文本字段中的数字?

iphone - 获取 UITableViewCell 文本的正确方法

ios - 如何在 ios 应用程序中实现数码相框?

objective-c - 将 Objective-C 对象向下转换为 Swift 类型失败(静默)