您的位置:首页 > 编程语言

在主线程里加入一个loading画面的多线程代码

2010-05-04 15:56 337 查看
这是CocoaChina版主 “superarts” 分享的一段多线程代码,在加载时生成一个Loading画面,既有启发性也有实际意义。帖子地址 http://www.cocoachina.com/bbs/read.php?tid-2967-fpage-2.html
{
[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];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐