[英]iOS NSOperation subclass freezes device rotation on execution
I need your help. 我需要你的帮助。 I have write my own custom NSOperation class called GetNewsOperation.
我已经编写了自己的自定义NSOperation类,称为GetNewsOperation。 I call it like this:
我这样称呼它:
GetNewsOperation *getNewsOperation = [[GetNewsOperation alloc] initWithLocalNewsCategories:self];
[loadNewsOperationQueue addOperation:getNewsOperation];
[getNewsOperation release];
In GetNewsOperation class I have implemented init method for initialization and main method for executing operation and returning data back to the main thread. 在GetNewsOperation I类已经实现用于执行操作和数据返回到主线程进行初始化和主要方法init方法。
Main method looks like this: 主要方法如下:
- (void)main {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
AppSettingsController *sharedAppSettingsController = [AppSettingsController sharedAppSettingsController];
if( [type isEqualToString:@"getCategory"] ) {
NSMutableArray *parsedData = [[NSMutableArray alloc] initWithArray:[sharedAppSettingsController getLocalNewsCategories]];
[newsViewController performSelectorOnMainThread:@selector(loadDataResponse:) withObject:[NSArray arrayWithObjects:parsedData, nil] waitUntilDone:NO];
[parsedData release]; parsedData = nil;
}
[pool release];
}
Everything works fine but I have a minor problem. 一切正常,但我有一个小问题。 When this operation is called application does not rotate on device orientation change.
调用此操作时,应用程序不会随着设备方向的变化而旋转。 It changes after operation is finished.
操作完成后它将改变。
As far as I know this operation is running for sure in new thread (not in main) cos all other elements in the app are active (not freezed). 据我所知,此操作肯定在新线程中运行(而不是在主线程中),因为该应用程序中的所有其他元素都处于活动状态(未冻结)。 But I have only problem with orientation.
但是我对方向只有问题。 The app looks kind a crappy if application does not rotate only when this operation occurs...
如果仅在执行此操作时应用程序不旋转,则该应用程序看起来很cr脚。
How can I solve this? 我该如何解决?
Thanks! 谢谢!
Actually it works like predicted. 实际上,它的工作原理与预期的一样。 I was doing something else on main thread that blocked application.
我在阻止应用程序的主线程上做了其他事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.