我陷入了隐藏的问题。我想从 Superview 中删除所有 UIProgressView。我正在以这种方式创建十字按钮,
crossButton = [[CCMenuItemImage alloc] initWithNormalSprite:[CCSprite spriteWithSpriteFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"close-bttn.png"]] selectedSprite:nil disabledSprite:nil block:^(id sender)
{
[self hideProgressBarForDownload];
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationInAppLayerClosed object:self userInfo:nil];
[[GameManager sharedGameManager]setCurrentLayer:-1];
[self removeFromParentAndCleanup:YES];
}];
当单击它时,会在层次结构中调用以下方法
-(void) hideProgressBarForDownload
{
[[DownloadManager sharedDownloadManager]removeAllProgressbarsIfvisible];
}
-(void)removeAllProgressbarsIfvisible
{
NSArray * allkeys = [currentDownloads allKeys];
for (int i = 0; i < [allkeys count]; i++)
{
NSString *key = [allkeys objectAtIndex:i];
DownloadItem * item = [currentDownloads valueForKey:key];
UIProgressView * progress = item.progressIndicator;
//progress.hidden = YES;
if (progress.superview)
{
[progress removeFromSuperview];
}
}
}
我猜每段代码都是正确的,但不知道为什么他们不删除。
提前致谢。