gpt4 book ai didi

ios - 我们能得到所有 Storyboard View 的数组吗

转载 作者:可可西里 更新时间:2023-10-31 23:44:49 26 4
gpt4 key购买 nike

我正在使用 Swift 开发应用程序。这个应用程序有很多 View ,我想在所有 View 上放置一个 UIProgressView

我们能否获得所有 Storyboard View 的数组?

例如:

    self.progressBar = UIProgressView(progressViewStyle: .Bar)
self.progressBar?.center = view.center
self.progressBar?.frame = CGRect(x: 0, y: 20, width: view.frame.width, height: CGFloat(1))
self.progressBar?.progress = 1/2
self.progressBar?.trackTintColor = UIColor.lightGrayColor();
self.progressBar?.tintColor = UIColor.redColor();

var arrayViewController : [UIViewController] = [...,...,...]

for controller in arrayViewController {
controller.view.addSubview(self.progressBar)
}

谢谢

是的

最佳答案

我假设您真正想要的是在每个 View 上显示进度(如果有操作正在进行)。

有很多方法可以做到这一点(使用委托(delegate),NSNotificationCenter,......)但我能想到的最简单的方法是依赖 viewWillAppear

override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)

// Check if there's an operation in progress and add progressView if relevant
}

对于用户来说,它看起来就像您将进度 View 添加到所有 View 一样。

关于ios - 我们能得到所有 Storyboard View 的数组吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30353005/

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