【发布时间】:2015-12-14 05:08:37
【问题描述】:
我有两个名为InterfaceController 和LoadInterfaceController 的类。
我正在通过我的LoadInterfaceController 拨打InterfaceController 的uiChange function:
InterfaceController *interfaceController = [InterfaceController alloc];
//[interfaceController performSelectorOnMainThread:@selector(uiChange) withObject:nil waitUntilDone:true];
[interfaceController uiChange];
function 被调用,但InterfaceController 中的 UI 未被修改。
- (void)uiChange {
NSLog(@"uiChange was called");
//... make changes to the UI ...
}
如果从源自InterfaceController class 的function 调用function,则分别更改UI。
我尝试在main thread 上调用uiChange(如here 所述),但用户界面没有响应。如何指定用于InterfaceController 的 UI 的线程?
【问题讨论】:
-
如果你调用的是 UI 相关的 API,那么它们必须在主线程上调用。
-
我已经尝试在主线程上调用它。 stackoverflow.com/questions/11582223/…
-
"try" 听起来不像你还在做。您必须使用主线程并从那里开始。
-
performSelectorOnMainThread、NSOperationQueue和dispatch_async不能解决问题。NSThread报告它正在main thread上运行。
标签: objective-c class watchkit nsthread watchos-2