这是错误:
-[UIApplication statusBarOrientation] 只能从主线程使用
statusBarOrientation在我的代码中的两个地方使用。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(positionHUD:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
这个在Objective-C .m文件中^^
UIInterfaceOrientation orientation = UIApplication.sharedApplication.statusBarOrientation;
请帮助提供任何线索或解决此问题。谢谢!
问题不太可能来自 (1(; 错误可能来自您从主线程以外的线程读取statusBarOrientation
成员。
这是从主线程读取statusBarOrientation
的方法:
dispatch_async(dispatch_get_main_queue(), ^(void){
// Now, we are in the context of the main (GUI) thread. You can perform any GUI updates here.
self.frame = [[[UIApplication sharedApplication] delegate] window].bounds;
UIInterfaceOrientation orientation = UIApplication.sharedApplication.statusBarOrientation;
// Put any other code that makes use of the "orientation" variable inside here
});
从现在开始,这完全取决于您要对orientation
变量执行的操作。