gpt4 book ai didi

ios - 在 UIAlertView 中重新定位 Activity Indicator

转载 作者:搜寻专家 更新时间:2023-10-31 23:03:46 25 4
gpt4 key购买 nike

我正在使用一个 UIAlertView,里面有一个 Activity 指示器,但指示器的位置不正确。我确定我遗漏了一些非常小的东西,但如果有人能帮助我,那就太好了。下面是我的代码和相应的代码片段

var progressAlert: UIAlertView = UIAlertView(title: "Downloading", message: "Patients information...", delegate: nil, cancelButtonTitle: nil);


var loadingIndicator: UIActivityIndicatorView = UIActivityIndicatorView()
loadingIndicator.center = CGPointMake(progressAlert.bounds.size.width/2, progressAlert.bounds.size.height - 150)
loadingIndicator.hidesWhenStopped = true
loadingIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
loadingIndicator.startAnimating()

progressAlert.setValue(loadingIndicator, forKey: "accessoryView")
progressAlert.show()

enter image description here

编辑:根据 Matt 的回答,最终创建了自定义 View ,效果非常好。

最佳答案

这里有两个问题。一是您正在假设 progressAlert 的最终大小 - 您正在根据 progressAlert 框架现在,而不是基于它出现时将会的样子。您可以通过使用约束而不是绝对 center 值来解决这个问题。

然而,更大的问题是你的所作所为是违法的。不要将您自己的 subview 添加到 UIAlertView。相反,用你自己的 View 制作你自己的 View Controller 并呈现它。它可以看起来像一个警报(即小,居中,使界面的其余部分变暗)但现在它是您的 View ,您可以在其中做任何您喜欢的事情。

关于ios - 在 UIAlertView 中重新定位 Activity Indicator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29657758/

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