gpt4 book ai didi

ios - 单击 "cross"按钮后无法从 super View 中删除 UIProgressView?

转载 作者:行者123 更新时间:2023-11-29 03:48:04 25 4
gpt4 key购买 nike

我陷入了隐藏的问题。我想从 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];
}
}
}

我猜每一段代码都是正确的,但不知道为什么他们没有删除。

提前致谢。

最佳答案

尝试这样,在按钮操作操作方法中放置此代码

for(UIView *view in self.view.subviews){
if([view isKindOfClass:[UIProgressView class]]))
[view removeFromSuperView];
}

关于ios - 单击 "cross"按钮后无法从 super View 中删除 UIProgressView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17446187/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com