我希望在一个专门用于音频的线程中运行的事件可以改变UI。简单地调用view.backgroundColor似乎没有任何效果。
这里有两种方法在我的viewController中。第一种是由触摸触发的。第二个是从音频代码调用的。第一个有效,第二个不起作用。有什么想法吗?
// this changes the color
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
[touchInterpreter touchesMoved:touches withEvent:event];
self.view.backgroundColor = [UIColor colorWithWhite: 0.17 + 2 * [patch getTouchInfo]->touchSpeed alpha:1];
};
// this is called from the audio thread and has no effect
-(void)bang: (float)intensity{
self.view.backgroundColor = [UIColor colorWithWhite: intensity alpha:1];
}
有什么想法吗?是我做了一些愚蠢的事情,还是改变UI元素的技巧在运行循环之外?