There is a task needs to draw N images on a NSView. But at the beginning I do not know the amount of images, so I set it works in a thread of background.
[NSThread detachNewThreadSelector:@selector(workInBackgroundThread:) toTarget:self withObject:nil];
在获得图像数量时,它将发出通知。
- (void)workInBackgroundThread:(id)unusedObject {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
//get image amount....
[[NSNotificationCenter defaultCenter] postNotificationName:@"gotImageAmount" object:nil];
//...
//continue to load images
}
我试图将NSView重新定位,取决于通知职能中的图像数量。
-(void)processGotImagesAmount:(NSNotification*)notification
{
//others codes
[myNSView setFrame:CGRectMake(0, 0, calculateNewWidth, caculatedNewHeight)];//line A
//others codes
}
但是,当这些评估执行A线时,它冻结了,
[myNSView setFrame:CGRectMake(0, 0, calculateNewWidth, caculatedNewHeight)];
如果我点击一个叫它的人,那就没有问题了。
但它认为它不履行通知职能。
欢迎任何意见