//viewcontroller.m
-(void)viewdidLoad
{
self.theOneViewController= [[TheOneViewController alloc]init];
[contentsView addSubview:self.theOneViewController.view];
}
//theOneViewController
- (void)viewDidLoad
{ .
.
.
//UI WORK
.
.
//LONG WORK
[self performSelectorOnMainThread:@selector(initAppList) withObject:nil waitUntilDone:NO];
}
this code, view display UI WORK before LONG WORK is end.So I can have a thread effect.
//viewcontroller.m
-(void) buttonPressed:(id)sender -> event method
{
self.theOneViewController= [[TheOneViewController alloc]init];
[contentsView addSubview:self.theOneViewController.view];
}
//theOneViewController
- (void)viewDidLoad
{ .
.
.
//UI WORK
.
.
//LONG WORK
[self performSelectorOnMainThread:@selector(initAppList) withObject:nil waitUntilDone:NO];
}
In this code, view display UI WORK after LONG WORK is end.
So I can't have thread effect. why?
And I use (performSelectorInBackground:withObject:) instead of (performSelectorOnMainThread withObject:waitUntilDone:) . but this is slower than not using thread.
I want to have thread effect in event method call.
Is there a good way? help me please!
No comments:
Post a Comment