我正在接近线程可可提供的新方法。 特别是,我创建一个新的线程使用可可触摸 - 线程和动画
[NSThread detachNewThreadSelector:@selector(myMethod) toTarget:self withObject:nil];
方法。
一切都很好,直到现在,但我遇到了一个奇怪的行为,也许你可以澄清我的事情。 例如,我的线程是:
-(void)myMethod{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
UIImage *img=[UIImage imageNamed:@"animage.png"];
UIImageView *imgV=[[UIImageView alloc]init];
[self.view addSubview:imgV];
[imgV setFrame:CGRectMake(100, 100, 200, 200)];
[imgV setImage:img];
[NSThread sleepForTimeInterval:10.5];
[imgV release];
[pool release];
}
我不明白为什么sleepForTimeInterval命令后,显示我的形象。 有什么想法?
谢谢。
我还没有意识到这一点。完成。 – Lorenzo 2011-03-09 18:05:39