NSThread and UIViewController Interaction

If I create a new stream and then inside it, I push the new controller to my UINavigationController using such code ...

(a) does not work

-(void)myCallbackInThread
{
    // move on...
    UIApplication* app = [UIApplication sharedApplication];
    [app changeView];
}

then I find that the view appears, but does not respond to user input.

If I changed code like this

(b) works

-(void)myCallbackInThread
{
    // move on...
    UIApplication* app = [UIApplication sharedApplication];
    [app performSelectorOnMainThread:@selector(moveToMain) withObject:nil waitUntilDone:FALSE];
}

Then everything works fine.

Any clues on why?

+5
source share
4 answers

, [app changeView], , , , , ( ). , , GUI . , .

, , , - , UIApplication . , performSelectorInMainThread, , gui . UIApplication .

, GUI . . ( , ..), (. NSRunLoop .)

+2

iPhone

, , . , . , Cocoa, , .

, -, , .

+2

: " , ".

, , , , . , , , , undefined, .

+2

UI- UIKit AppKit . , , , , , -, , .

- , , .

0
source

All Articles