我安装了同时装有iOS 12.1的iPhone和iPad,通过Xcode 10.1编译我的快速代码并测试我的应用程序时,我注意到当我开始上传时,我的子视图在iPad,但是当我使用iPhone进行测试时,子视图将移动到屏幕上UIAlertController消息的中心附近。
我认为这与屏幕大小的变化有关,例如iPad和iPhone,这会使屏幕上的警报消息缩小一点,然后进度条会将警报消息向上移动一点。我不确定它是否是我的代码,我在下面添加了此图片和我的代码。任何帮助都将是一件幸事,在此先感谢您。
var alert : UIAlertController!
var progressUpload : UIProgressView!
self.alert = UIAlertController(title: "Updating",
message: "Please wait for update to complete..",
preferredStyle: .alert)
self.alert.addAction(UIAlertAction(title: "Cancel", style: .default, handler:
{ (action: UIAlertAction!) in }))
let rect = CGRect(x: 10, y: 70, width: 220, height: 0)
self.progressUpload = UIProgressView(frame: rect)
self.progressUpload.setProgress(0.0, animated: true)
self.progressUpload.transform = CGAffineTransform(scaleX: 1, y:2)
self.progressUpload.progressTintColor = UIColor.blue
self.progressUpload.layer.cornerRadius = 5
self.progressUpload.clipsToBounds = true
//adds to alert message
self.alert.view.addSubview(self.progressUpload)
self.present(self.alert, animated: true, completion: nil)