Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/107.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS-UIAlert仅显示“警告”;“好的”;将应用程序图标更改为备用图标后_Ios_Swift_Appicon - Fatal编程技术网

iOS-UIAlert仅显示“警告”;“好的”;将应用程序图标更改为备用图标后

iOS-UIAlert仅显示“警告”;“好的”;将应用程序图标更改为备用图标后,ios,swift,appicon,Ios,Swift,Appicon,我在一个地方更改我的应用程序的应用程序图标。我可以得到它,这样应用程序图标实际上会改变,但是,应该弹出的警报只显示“OK”。没有文本或图片表明图标已更改 我想知道视图层次结构是否有问题?我尝试在我的应用程序中的多个位置放置更改功能,每次都会更改图标,但警报仍然错误。另外,我在打印到控制台时也找不到任何错误 以下是我调用图标更改的代码: UIApplication.shared.setAlternateIconName(ThemeCenter.shared.alternateIconName,

我在一个地方更改我的应用程序的应用程序图标。我可以得到它,这样应用程序图标实际上会改变,但是,应该弹出的警报只显示“OK”。没有文本或图片表明图标已更改

我想知道视图层次结构是否有问题?我尝试在我的应用程序中的多个位置放置更改功能,每次都会更改图标,但警报仍然错误。另外,我在打印到控制台时也找不到任何错误

以下是我调用图标更改的代码:

UIApplication.shared.setAlternateIconName(ThemeCenter.shared.alternateIconName, completionHandler: nil)
我希望警报会告诉用户应用程序图标已更改,并显示图标更改为的图像,如下所示:
据我所知,这应该会自动发生。

您可以创建警报并向其添加图像视图:

let showAlert = UIAlertController(title: "Demo Alert", message: nil, preferredStyle: .alert)
let imageView = UIImageView(frame: CGRect(x: 10, y: 50, width: 250, height: 230))
imageView.image = image // Your image here...
showAlert.view.addSubview(imageView)
let height = NSLayoutConstraint(item: showAlert.view, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 320)
let width = NSLayoutConstraint(item: showAlert.view, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 250)
showAlert.view.addConstraint(height)
showAlert.view.addConstraint(width)
showAlert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
    // your actions here...    
}))
self.present(showAlert, animated: true, completion: nil)

您可以根据需要更改尺码

问题在于,在代码中的某个地方,我们扩展了
UIAlertController
,并覆盖了
viewDidLoad
,以设置着色颜色。出于某种原因,此覆盖使警报顶部不显示。取出
viewdiload
覆盖解决了问题。

问题在于它不会停止“OK”按钮的显示,因为它内置于
setAlternateCON
功能中。然而,弹出我自己的UIAlert函数确实可以很好地工作。