ios - Progress View不想隐藏

标签 ios objective-c cocoa-touch uiview

再次出现奇怪的行为,这次来自 progressView。 在我的 .h 文件和 .m 文件中定义了一个 progressView :

.h 文件:

IBOutlet UIProgressView *progressView;

.m 文件:

self.progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];

self.progressView.center = CGPointMake(390, 70);
[self.view addSubview:self.progressView];
self.progressView.hidden = YES;

当我需要它显示时,只需将 .hidden 属性设置为 NO 它就会显示出来,很好地完成它的工作。 但问题是,当工作完成后,我想让它离开舞台,但它不会......

我试过了:

[self.progressView removeFromSuperview];
self.progressView.hidden = YES;
self.progressView.alpha = 0.0f;

当然不是在同一时间,但没有任何效果。就像它与 View 断开连接一样,我不明白为什么。

有人有什么绝妙的(像往常一样)想法吗???

谢谢,希望明天能和别人讨论,现在该 sleep 了....

享受

最佳答案

尝试

@property(weak) IBOutlet UIProgressView *progressView;

UIProgressView *progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
[self.view addSubview:progressView];
self.progressView = progressView;
self.progressView.center = CGPointMake(390, 70);

以后

[self.progressView removeFromSuperview];

可能是您的代码释放进度 View 的速度过快,您的属性(property)/商店不再引用它。

使用我的代码,在将进度 View 分配给不拥有的属性之前, View 将拥有进度 View 。

关于ios - Progress View不想隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27411728/

相关文章:

ios - 完成 block Swift 后设置标签文本

ios - UITableView insertRowsAtIndexPaths :WithRowAnimation without freeze UI

iphone - 我们可以将属性/合成到 sqlite3 * 数据库对象吗?

ios - 如何在没有 Storyboard的情况下学习 iOS 编程?

ios - UIView的frame.height和frame.size.height有什么区别?

IOS AdaptiveView Popover 和 NavigationController : how do they work?

ios - 了解 iOS 中的 KVO

ios - 父/子 NSManagedObjectContext 的正确实现

ios - AVSpeechSynthesis 结束

objective-c - UITextField "value changed"字段更新时未触发