Sunday, April 12, 2009
在线程中更新界面
在线程中调用 -(void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait, 然后再在这个函数里面刷新界面的control。
在主线程里加入一个loading画面…
{
[window addSubview:view_loading];
[NSThread detachNewThreadSelector:@selector(init_backup:) toTarget:self withObject:nil];
}
- (void)init_backup:(id)sender
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// ...
int i = status;
[self performSelectorOnMainThread:@selector(show_loading:) withObject:[NSNumber numberWithInt:i] waitUntilDone:NO];
[view_loading removeFromSuperview];
[window addSubview:tabcontroller_main.view];
[pool release];
}
NSTimer检测不到按键的解决办法
在Timer的执行函数最后加上这段代码就可以了。
[[NSRunLoop currentRunLoop] runUntilDate: [NSDate distantPast]];
[[NSRunLoop currentRunLoop] runUntilDate: [NSDate distantPast]];
Subscribe to:
Comments (Atom)
