开发者

iOS NSOperation subclass freezes device rotation on execution

开发者 https://www.devze.com 2023-03-26 08:57 出处:网络
I need your help. I have write my own custom NSOperation class called GetNewsOperation. I call it like this:

I need your help. I have write my own custom NSOperation class called 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.

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...

How can I solve this?

Thanks!


Actually it works like predicted. I was doing something else on main thread that blocked application.

0

精彩评论

暂无评论...
验证码 换一张
取 消